javascript消除window.close()的提示窗口
Window.close()這句腳本是用來關(guān)閉當(dāng)前窗口,如果是在window.open的窗口中執(zhí)行Window.close(),將會很順利地將窗口關(guān)閉,但如果是在一非window.open打開的窗口中執(zhí)行Window.close(),將會彈出一個提示窗口,如下:
要在程序中消除這個提示框也很簡單,不過在IE6和IE7稍有不同
1. IE6
<html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>IE6Close</title> <script type="text/javascript"> function closeWin() { window.opener=null; window.close(); } </script> </head> <body> <form id="form2" runat="server"> <div> <input id="btnClose" type="button" value="close" onclick="closeWin()"/> </div> </form> </body> </html>
2.IE7
<html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>IE7Colse</title> <script type="text/javascript"> function closeWin() { window.open('','_self',''); window.close(); } </script> </head> <body> <form id="form2" runat="server"> <div> <input id="btnClose" type="button" value="close" onclick="closeWin()"/> </div> </form> </body> </html>
以上所述就是本文的全部內(nèi)容了,希望大家能夠喜歡。
相關(guān)文章
JavaScript根據(jù)json生成html表格的示例代碼
這篇文章主要介紹了JavaScript根據(jù)json生成html表格的示例代碼,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-10-10Bootstrap每天必學(xué)之折疊(Collapse)插件
Bootstrap每天必學(xué)之折疊(Collapse)插件,折疊插件可以很容易地讓頁面區(qū)域折疊起來,感興趣的小伙伴們可以參考一下2016-04-04uniapp自定義頁面跳轉(zhuǎn)loading的實(shí)現(xiàn)代碼
有些頁面加載起來比較慢,為了加強(qiáng)用戶體驗(yàn)效果,所以一般都會做一個頁面加載等待的提示,頁面加載完成后消失,下面這篇文章主要給大家介紹了關(guān)于uniapp自定義頁面跳轉(zhuǎn)loading的實(shí)現(xiàn)代碼,需要的朋友可以參考下2023-06-06H5實(shí)現(xiàn)仿flash效果的實(shí)現(xiàn)代碼
這篇文章主要介紹了H5實(shí)現(xiàn)仿flash效果的實(shí)現(xiàn)代碼的相關(guān)資料,希望通過本文能幫助到大家,實(shí)現(xiàn)這樣的功能,需要的朋友可以參考下2017-09-09