/ Published in: JavaScript
Not my code. See: http://www.netlobo.com/urlquerystring_javascript.html
Expand |
Embed | Plain Text
function gup( name ) { name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regexS = "[\\?&]"+name+"=([^&#]*)"; var regex = new RegExp( regexS ); var results = regex.exec( window.location.href ); if( results == null ) return ""; else return results[1]; } // Example: gup('cat') will give you "meow" if the URL is http://example.com/?cat=meow
Comments
Subscribe to comments
You need to login to post a comment.

Very nice one.