Window.close()這句腳本是用來關(guān)閉當(dāng)前窗口,如果是在window.open的窗口中執(zhí)行Window.close(),將會(huì)很順利地將窗口關(guān)閉,但如果是在一非window.open打開的窗口中執(zhí)行Window.close(),將會(huì)彈出一個(gè)提示窗口,如下:

要在程序中消除這個(gè)提示框也很簡(jiǎn)單,不過在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>以上所述就是本文的全部?jī)?nèi)容了,希望大家能夠喜歡。
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注