喽游网
您的当前位置:首页javascript打开新窗口同时关闭旧窗口_javascript技巧

javascript打开新窗口同时关闭旧窗口_javascript技巧

来源:喽游网


其实这个问题和浏览器的版本息息相关,作为菜鸟的我,直到现在也没有找到完美的解决办法。没办法,因为业务必须要实现,所以只好用另一种方法去做了:
通过重定向URL实现打开新窗口的同时“关闭”旧窗口
test1.html



test1






function toNewWindow() {
window.top.location.href="test2.html";
}





test2.html



test2.html






通过重写URL,打开了要跳转的页面test2.html


附:页面跳转的各种方法
第一种:

window.location.href="/login.jsp?backurl="+window.location.href;

第二种:

alert("返回");
window.history.back(-1);

第三种:

window.navigate("top.jsp");

第四种:

self.location='top.htm';

第五种:

alert("非法访问!");
top.location='xx.jsp';

=====javascript中弹出选择框跳转到其他页面=====

function logout()...{
if (confirm("你确定要注销身份吗?是-选择确定,否-选择取消"))...{
window.location.href="/logout.asp?act=logout"
}
}
-->

=====javascript中弹出提示框跳转到其他页面=====

function logout()...{
alert("你确定要注销身份吗?");
window.location.href="/logout.asp?act=logout"
}
-->
显示全文