HTML页面如何象ASP一样接受参数
HTML页面如何象ASP一样接受参数
发布时间:2016-12-30 来源:查字典编辑
摘要:复制代码代码如下:varpos,str,para,parastr,tempstr1;tempstr="";str=window.locati...

复制代码 代码如下:

<scriptlanguage="JavaScript"type="text/javascript">

varpos,str,para,parastr,tempstr1;

tempstr="";

str=window.location.href;

pos=str.indexOf("?")parastr=str.substring(pos+1);

document.write("<br>文件路径:"+str);

if(pos>0)

{

document.write("<br>所有参数:"+parastr);

}

else

{

document.write("无参数");

}

if(str.indexOf("&")>0)

{

para=parastr.split("&");

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

{

tempstr1=para[i];

pos=tempstr1.indexOf("=");

//document.write(tempstr1.substring(0,pos));

document.write("<br>参数"+i+":"+tempstr1.substring(0,pos));

document.write("等于:"+tempstr1.substring(pos+1));

}

}

</script>

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新Javascript教程学习
热门Javascript教程学习
编程开发子分类