Last time when I was working in a HTML file I was needed to read the query string values and wanted to do some dynamic operations with those, but you know we cannot straight away read the query string values unless we use a server side technology.
So I searched in the Internet got a lot of examples but most of them are used Regular expression. I’m not quite comfortable with Regular Expressions, So I decided to find a simple script which anybody can easily understand it.
Here is the script:
//get all query strings from url
var allQS = window.location.search.substring(1);
//split the query strings by &
var splitQS = allQS.split('&');
//loop through all strings
for (var i = 0; i < splitQS.length; i++)
var singleQS = splitQS[i].split('=');
//check the single QS and the param passed is matched, if true then return
if (singleQS == qParam)
And here is the demo: