如果網頁不是通過腳本程序打開的(window.open()),調用window.close()腳本關閉窗口前,必須先將window.opener對象置為null,否則瀏覽器(IE7、IE8)會彈出一個確定關閉的對話框。
<script language="javaScript">
function closeWindow()
{
window.opener = null;
window.open(' ', '_self', ' ');
window.close();
}
</script>
<input type='button' value='關閉窗口' onClick="closeWindow()">???
或
<input type="button" value="關閉窗口" onClick="window.opener = null; window.open(' ', '_self', ' ');window.close()">
?
對于關閉框架窗口
<script language="javaScript">
function closeWindow()
{??
???? window.opener = null;??
???? window.open('', '_top', '');??
???? window.parent.close();?
}?
</script>