第一种:
<script language="javascript" type="text/javascript">
window.location.href="login.jsp?backurl="+window.location.href;
</script>
第二种:
<script language="javascript">
alert("返回");
window.history.back(-1);
</script>
第三种:
<script language="javascript">
window.navigate("top.jsp");
</script>
第四种:
<script language="JavaScript">
self.location=’top.htm’;
</script>
第五种:
<script language="javascript">
alert("非法访问!");
top.location=’xx.jsp’;
</script>
window.location="";和 location.replace("");有什么区别?
replace(),reload()是重新加载本页,而replace()可以导向另外一个URL
1.我们现在有3个页面(a.html, b.html, c.html).默认打开a.html页面,然后在a.html页面中通过一个链接转向a.html页面。
2.现在,我在b.html页面中用window.location.replace("c.html");与用window.location.href("c.html");分别进入c.html页面.从用户界面来看是没有什么区别的,
3.在c.html页面有一个“返回”按钮,用window.location.href("c.html");进入c.html页面后,在c.html页面中的调用window.history.go(-1);wondow.history.back();点击"返回"按钮,返回 b.html页面,
4.而如果用window.location.replace("c.html");进入c.html页面,在c.html页面中的调用window.history.go(-1);wondow.history.back();方法是不好用的,点击"返回"按钮,返回到 a.html页面。
5.因为window.location.replace("c.html");是不会向服务器发送请求而进行跳转,
6.而window.location.href("c.html");是向服务器发送请求的跳转,
7.window.history.go(-1);wondow.history.back();方法是根据服务器记录的请求决定该跳到哪个页面的,所以就可以返回到b.html。