If you are trying to get parameter values from querystring and you are already using JQuery, then you can try out this plugin which will get q-string params for you.
jQuery-URL-Parser
I haven't tried it , but it seems it will work for you in the following format...
var var1ParamResult = $.url('http://www.mypage.com/page1.aspx?var1=123&var2=987').param('var1');
The value '123' should be inside var1ParamResult variable. If the plugin doesn't work for you, there are methods that can do what you need using vanilla JS and regular expressions to sift through the url of the page.