/ Published in: jQuery

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); return results[1] || 0; } // example.com?someparam=name&otherparam=8&id=6 $.urlParam('someparam'); // name $.urlParam('id'); // 6 $.urlParam('notavar'); // null
Comments
