html获取url参数例
var pos,str,para,parastr,tempstr1;
tempstr="";
str = window.location.href;
pos = str.indexOf("?")
parastr = str.substring(pos+1);
document.write("
文件路径:"+str);
if (pos>0){
document.write("
所有参数:"+parastr);
}
else
{
document.write ("无参数");
}
if (str.indexOf("&")>0){
para = parastr.split("&");
for(i=0;i
{
tempstr1 = para[i];
pos = tempstr1.indexOf("=");
//document.write (tempstr1.substring(0,pos));
document.write ("
参数"+i+":"+tempstr1.substring(0,pos));
document.write ("等于:"+tempstr1.substring(pos+1));
}
}
===========================================================
JavaScript的location.search属性可以返回当前网页URL中?后面的部分,例如:
当前网页地址:http://bbs.dvbbs.net/dispbbs.asp?boardID=1&ID=1212500&page=2
location.search返回值就是 ?boardID=1&ID=1212500&page=2
iframe动态显示获取url
var pos,str,para,parastr;
tempstr="";
str = window.location.href;
pos = str.indexOf("?")
parastr = str.substring(pos+1);
//将参数打出来window.alert(parastr);
if (pos>0){
document.write("
");document.write("
");document.write("");
document.write("");
document.write("
");document.write("");
document.write("");
}
else
{
//document.write ("无参数");//+parastr+
}