js 获取地址栏参数

//获取地址栏当中的参数信息

function getparastr(strname){ 

var hrefstr,pos,parastr,para,tempstr; 

hrefstr = window.location.href; 

pos = hrefstr.indexOf("?")

parastr = hrefstr.substring(pos+1); 

para = parastr.split("&"); 

tempstr=""; 

for(i=0;i<para.length;i++){ 

tempstr = para[i]; 

pos = tempstr.indexOf("="); 

if(tempstr.substring(0,pos) == strname){ 

  return tempstr.substring(pos+1); 

 } 

return null; 

}

猜你喜欢

转载自it1990eye0920.iteye.com/blog/2300742