Latest news
Home » Tag Archives: jquery url parameters

Tag Archives: jquery url parameters

Get URL parameters using javascript or jquery

Example URL http://smarttips.in?newsletter=1 <script> var queryString = (function(url) { if (url == “”) return {}; var smart = {}; for (var i = 0; i < url.length; ++i) { var pS=url[i].split(‘=’, 2); if (pS.length == 1) smart[pS[0]] = “”; else smart[pS[0]] = decodeURIComponent(pS[1].replace(/+/g, “””)); } return pS; })(window.location.search.substr(1).split(‘&’)); $(document).ready(function(){ if(queryString[“newsletter”]==1) { alert(‘Got it!!!’) } }); </script>

Read More »