/ Published in: JavaScript
Many thanks to bloggingdeveloper.com for this one. Works like a charm. Usage is similar to server side built-in functions.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function getQuerystring(key, default_) { if (default_==null) default_=""; key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regex = new RegExp("[\\?&]"+key+"=([^&#]*)"); var qs = regex.exec(window.location.href); if(qs == null) return default_; else return qs[1]; }