在开发项目过程中,需要用到跳转页面来循环执行任务的方法,现在把在网上搜的js页面跳转常用的几种方式记录一下:
第一种:
<script language="javascript" type="text/javascript"> window.location.href = "http://www.qianmu.net/?backurl=" + window.location.href; </script>
第二种:
<script type="text/javascript"> alert("返回"); window.history.back( - 1); </script>
第三种:
<script type="text/javascript"> window.navigate("http://www.qianmu.net/"); </script>
第四种:
<script type="text/javascript"> self.location = 'http://www.qianmu.net/'; </script>
第五种:
<script type="text/javascript"> alert("非法访问!"); top.location = 'http://www.qianmu.net/'; </script>
第六种:
<script type="text/javascript"> function request(paras) { var url = location.href; var paraString = url.substring(url.indexOf("?") + 1, url.length).split("&"); var paraObj = {} for (i = 0; j = paraString[i]; i++) { paraObj[j.substring(0, j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=") + 1, j.length); } var returnValue = paraObj[paras.toLowerCase()]; if (typeof(returnValue) == "undefined") { return ""; } else { return returnValue; } } var theurl theurl = request("url"); if (theurl != '') { location = theurl } </script>