Welcome To Snipplr
Everyone's Recent JavaScript Snippets
- All /
- JavaScript /
- HTML /
- PHP /
- CSS /
- Ruby /
- Objective C
The usual way to shuffle an array uses the .sort() method with Math.round(Math.random())-0.5
This solution is highly biased based on the sort algorithm used by the browsers. A sort comparison operation has to fulfill the condition "if a>b then b<a"...
        
        
        
            0 
        
        
            1149 
        
                    posted 13 years ago by devnull69
            Some FB apps are longer than the 800px default FB limit and most are designed to 520px. When your content is longer than the 800px default a verticle scroll bars appears and if you have a hard-coded width in your CSS of 520px this forces a horizontal...
        
        
        
            0 
        
        
            1345 
        
                    posted 13 years ago by the_construct
            Convert a form submit button code to a hyperlink code and hide the form
        
        
        
            0 
        
        
            2149 
        
                    posted 13 years ago by pavlosvos
            Usage:
<a href="http://www.whaterver-your-site-is-called.com/" rel="external">Some other site</a>
        
        
        
            0 
        
        
            2542 
        
                    posted 13 years ago by Krummelz
            If you a flick a web app past the bottom or top of the page, the page itself gets elastically tugged away from the URL bar or the button bar (or the bottom/top of the screen if it's in full-screen mode).
This behavior is another giveaway that your...
        
        
        
            0 
        
        
            2114 
        
                    posted 13 years ago by timothypwalter
            Grab jQuery library from Google's CDN this way its faster, burns Google's bandwidth and not yours. Also users will have this cached if other sites are using it as well. 
Downside of course is Google's servers do go down. This script will check if...
        
        
        
            1 
        
        
            1317 
        
                    posted 13 years ago by cyberpunkstudio
            The Google Closure lets you get DOM elements with getElement( id ) and getElementByClass( class ).  This function combines the two to let you get elements similarly to the way jQuery does.  E.g. getElement( '#home .sidebar #links') returns the elemen...
        
        
        
            0 
        
        
            1780 
        
                    posted 13 years ago by cjcenizal
            Usually when working with form you use a server to handle it, and if your doing it entirely in javascript no reload is required, but what if you wanted to take the information and use it in a javascript on another page, completely client side. I had...
        
        
        
            0 
        
        
            2561 
        
                    posted 13 years ago by FatFolderDesigner
            Go through all the authors of a wordpress import and make them the same as the previous authors (Wordpress 3.3).
        
        
        
            0 
        
        
            1202 
        
                    posted 13 years ago by jcottrell
            Delete a page of wordpress posts with one click ("Run" in Firebug or Developer Tools)
        
        
        
            0 
        
        
            1052 
        
                    posted 13 years ago by jcottrell
            Find the date with or without a year and with double or single digit month or day.  Easily extendable to other date delimiters and formats.
        
        
        
            0 
        
        
            2568 
        
                    posted 13 years ago by pumpkinthehead
            extends the default varien "tabs" class to allow other links on the page to open a tab
        
        
        
            0 
        
        
            2215 
        
                    posted 13 years ago by flintcreative
            How to get extract method for zipfile module to work with Ti 1.8 sdk.
        
        
        
            0 
        
        
            1400 
        
                    posted 13 years ago by lspellman
            <p>This is how the extract method is documented for use. In the next example, we show how it actually should be used for Ti 1.8</p>
        
        
        
            0 
        
        
            1303 
        
                    posted 13 years ago by lspellman
            Esto es por si estamos desarrollando una aplicación en la cual necesitamos manejar la fecha y hora con javascript.
        
        
        
            0 
        
        
            1271 
        
                    posted 13 years ago by jrobinsonc
            In JavaScript, there are 6 "falsy" values (values that evaluate to false):
false, null, undefined, 0, "" (the empty string), and NaN
Anything else evaluates to true.
        
        
        
            0 
        
        
            1014 
        
                    posted 13 years ago by goo
            This will return the value of "param" form the URI. For example if you have 
www.example.com/index.html?param=some_value
it will return "some_value".
NOTE! This only works if you use Prototype JavaScript framework.
        
        
        
            0 
        
        
            2264 
        
                    posted 13 years ago by srka
            Helps to manage console.log debug in js when broswing in IE. If alertFallback is enabled, you can see js alerts appears of vars tracked.
        
        
        
            0 
        
        
            2222 
        
                    posted 13 years ago by Simounet
            By not being limited to provide certain arguments/parameters in right order when calling a function, makes the function more versatile and easier to extend without breaking old code (e.g. calls to the function). 
One solution is to pass an associati...
        
        
        
            0 
        
        
            1592 
        
                    posted 13 years ago by coprolit
            Sorts a list by its 'data-' attribute. Customization is very easy.
        
        
        
            0 
        
        
            1415 
        
                    posted 13 years ago by inreflection7
            
