adapt this to your code and try:
var theUrl="
http://mysite.org?variable1=a&variable2=2";
var urlPart = theUrl.split("?")[1];//the
parameters in a url allways follow the question simbol (?)
var arrparams = urlPart.split("&");//the parameters in a url allways are separated by and &
for(var i=0; i< arrparams.length;i++){
var nameAndValue = arrparams[i].split("=");//
the params allways are pairs separated by a equals(=);
var name=nameAndValue [0];
var value=nameAndValue [1];
alert("Name= "+name+"\nValue= "+value);
}