首页 >web前端 >js教程 >HTML页面如何象ASP一样接受参数_javascript技巧

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

WBOY
WBOY原创
2016-05-16 19:19:39978浏览
复制代码 代码如下:

<script> <BR>var pos, str, para, parastr, tempstr1; <BR>tempstr = ""; <BR>str = window.location.href; <BR>pos = str.indexOf("?")parastr = str.substring(pos + 1); <BR>document.write("<br>文件路径:" + str); <BR>if (pos > 0) <BR>{ <BR>document.write("<br>所有参数:" + parastr); <BR>} <br><br>else <BR>{ <BR>document.write("无参数"); <BR>} <br><br><BR>if (str.indexOf("&") > 0) <BR>{ <BR>para = parastr.split("&"); <BR>for (i = 0; i < para.length; i++) <BR>{ <BR> tempstr1 = para[i]; <br><br> pos = tempstr1.indexOf("="); <BR> //document.write (tempstr1.substring(0,pos)); <BR> document.write("<br>参数" + i + ":" + tempstr1.substring(0, pos)); <BR> document.write("等于:" + tempstr1.substring(pos + 1)); <BR>} <BR>} <BR></script>

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn