Home  >  Article  >  Web Front-end  >  javascript 页面只自动刷新一次_javascript技巧

javascript 页面只自动刷新一次_javascript技巧

WBOY
WBOYOriginal
2016-05-16 18:50:151087browse
1.看看下面这段代码
复制代码 代码如下:

<script> <BR>function reurl(){ <BR>url = location.href; //把当前页面的地址赋给变量 url <BR>var times = url.split("?"); //分切变量 url 分隔符号为 "?" <BR>if(times[1] != 1){ //如果?后的值不等于1表示没有刷新 <BR>url += "?1"; //把变量 url 的值加入 ?1 <BR>self.location.replace(url); //刷新页面 <BR>} <BR>} <BR>onload=reurl <BR></script>

2.原理
充分利用地址栏可带参数的选项,用脚本来取得页面间的传递参数,并不需要后台程序的支持。
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