/ Published in: jQuery

This is an improvement on http://snipplr.com/view/11583/retrieve-url-params-with-jquery/
I found IE wasn't liking the results[1] when no param was set. This fixes that issue.
I found IE wasn't liking the results[1] when no param was set. This fixes that issue.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$.urlParam = function(name){ var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href); if (!results) { return 0; } return results[1] || 0; }
Comments
