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();