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

 
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM