Home  >  Article  >  Web Front-end  >  HTML页面如何象ASP一样接受参数_javascript技巧

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

WBOY
WBOYOriginal
2016-05-16 19:19:39919browse
复制代码 代码如下:

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn