首页 > 精选文章 > HTML&CSS > 正文

HTML页面如何象ASP一样接受参数

<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[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>

  • 上一篇:柳传志反思联想20年:应该做什么样的自我检讨?
  • 下一篇:一搜Vs.Google:论文搜索大比拼
  • 了解这些字:页的意思 面的意思 如的意思 何的意思 象的意思 一的意思 样的意思 接的意思