js打开新页面 关闭当前页 关闭父页面

js打开新页面.关闭当前页.关闭父页面  

2010-04-29 14:04:13|  分类: 页面与JavaScript |  标签: |字号 订阅

 
 

//关闭当前页面,并且打开新页面,(不提示)

function closeWinAndOpen(url) {

    var sWinName = "LR"+parseInt(Math.random() * 100000000);//利用随机数处理WinName

    window.open(url,sWinName, 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=yes,copyhistory=yes');

    closeWin();

}

//关闭当前页面

function closeWin() {

    window.opener=null;

    window.open('','_self');

    window.close();

}

关闭父页面:

Response.Write("<script>window.top.opener=null;window.parent.close();</script>")

(window.opener.top.close() 也好使) 

设置window.opener=null 可以不显示:"您查看的网页正在试图关闭窗口,是否关闭窗口"

ie7关闭不提示

window.opener=null;//如果后面需要用openner,这一行可以去掉
window.open('','_top');
window.top.close();

 
 
原文地址:https://www.cnblogs.com/gaoxue/p/3286817.html