JSFiddle

  • Multiline strings in JS #9 is the latest revision

    A test for @tjanczuk's method for multi-line string via comments in the browser

    window.onload = function(){
        document.body.innerHTML = '<select multiple><option>' +
        countries.replace(/\n\b/g,'</option><option>') +
        '</select>';
    }
    
    function uncomment(fn){
      return fn.toString().split(/\/\*\n|\n ...
  • Remember — unstyled selects with multiple options are a usability nightmare anyway

    In support of @PaulRobertLloyd's woes https://twitter.com/paulrobertlloyd/status/341591914744778753

    <select multiple=""><option></option><option>Afghanistan</option><option>Albania</option><option>Algeria</option><option>Andorra</option><option>Angola</option><option>Antigua and Barbuda</option><option>Argentina</option><option>Armenia</option><option>Australia</option><option>Austria</option><option>Azerbaijan</option><option>The Bahamas</option><option>Bahrain</option><option>Bangladesh</option><option>Barbados</option><option>Belarus</option><option>Belgium ...</option></select>
  • Remember — unstyled selects with multiple options are a usability nightmare anyway

    In support of @PaulRobertLloyd's woes https://twitter.com/paulrobertlloyd/status/341591914744778753

    window.onload = function(){
        document.body.innerHTML = '<select multiple><option>' +
        countries.replace(/\n\b/g,'</option><option>') +
        '</select>';
    }
    
    var countries = (function(){/*
    Afghanistan
    Albania
    Algeria
    Andorra
    Angola
    Antigua ...
  • Cross-browser gradient application with native JS - now with IE support!

    In response to a question at http://stackoverflow.com/questions/16218902/how-can-i-change-a-css-gradient-via-javascript/16219600#16219600

    var makeGradientStyle = function(){
        var gradientString = '\
            /* Mozilla Firefox */ \
            background-image: -moz-linear-gradient(top, {colour1} 0%, {colour2} 100%);\
            /* Opera */ \
            background-image: -o-linear-gradient(top, {colour1} 0 ...
  • Cross-browser gradient application with native JS - now with IE support! #2 is the latest revision

    In response to a question at http://stackoverflow.com/questions/16218902/how-can-i-change-a-css-gradient-via-javascript/16219600#16219600

    var makeGradientStyle = function(){
        var gradientString = '\
            /* Mozilla Firefox */ \
            background-image: -moz-linear-gradient(top, {colour1} 0%, {colour2} 100%);\
            /* Opera */ \
            background-image: -o-linear-gradient(top, {colour1} 0 ...
  • Cross-browser gradient application with native JS — including IE #1 is the latest revision

    In response to a question at http://stackoverflow.com/questions/16218902/how-can-i-change-a-css-gradient-via-javascript/16219600#16219600

    var makeGradientStyle = function(){
        var gradientString = '\
            /* Mozilla Firefox */ \
            background-image: -moz-linear-gradient(top, {colour1} 0%, {colour2} 100%);\
            /* Opera */ \
            background-image: -o-linear-gradient(top, {colour1} 0 ...
  • Sticky (position absolute or fixed depending on visibility) #6 is the latest revision

    In response to a question at http://stackoverflow.com/questions/16441226/always-show-a-div-as-soon-as-its-not-visible-any-more-after-scrolling-down/16441526

    var stick = document.getElementById('stick');
    
    window.onscroll = function(){
        if(stick.getBoundingClientRect().top < 0){
            stick.className = 'fixed';
        } else if(stick.className ...
  • Cross-browser gradient application with native JS #14 is the latest revision

    In response to a question at http://stackoverflow.com/questions/16218902/how-can-i-change-a-css-gradient-via-javascript/16219600#16219600

    var makeGradientStyle = function(){
        var gradientString = '\
            /* Mozilla Firefox */ \
            background-image: -moz-linear-gradient(top, {colour1} 0%, {colour2} 100%);\
            /* Opera */ \
            background-image: -o-linear-gradient(top, {colour1} 0 ...
  • Replace esoteric syntax with HTML #3 is the latest revision

    In response to a question at http://stackoverflow.com/questions/16212144/rebulid-href-tag-from-text-with-jquery

    var $target     = $('.msg_body p');
    
    var text        = $target.text();
    
    var replacement = text.replace(/\|URI=([^\|]+)\|([^\|]+)\|EURI\|/g, function(string, url, text){
      return ...
  • Setting minimum size limit for a window minimization of browser? #108 is the latest revision

    In response to a question at http://stackoverflow.com/questions/16173965/setting-minimum-size-limit-for-a-window-minimization-of-browser

    void function(){
        var popup;
        var resizing;
        
        try{
            if(window.name === 'popup'){
                return $('body').html('This window should have a minimum ...