岁月联盟 - 技术社区 - BBS.SYUE.COM's Archiver

猪猪 发表于 2007-2-11 15:01

让HTML页面象asp一样接受参数

[code]<script language="javascript">
var pos,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;

pos = tempstr1.indexOf("=");
//document.write (tempstr1.substring(0,pos));
document.write ("<br>参数"+i+":"+tempstr1.substring(0,pos));
document.write ("等于:"+tempstr1.substring(pos+1));
}
}
</script>[/code]

cofan 发表于 2007-4-25 11:08

抄下来看看

mywolf 发表于 2008-4-21 14:48

好东西!!!谢谢!!

cht_by4 发表于 2008-8-21 15:09

[(:sweat:)] 有什么用的?

页: [1]

Powered by Discuz! Archiver 7.0.0  © 2001-2009 Comsenz Inc.