|
關(guān)鍵字: 用javascript來關(guān)閉ie瀏覽器和firefox瀏覽器
原文地址:http://hi.baidu.com/suen_%CB%EF/blog/item/bedca57f8932480d28388a49.html
眾所周知,在javascript中 window.close()是用來關(guān)閉窗口的,而且ie和firefox都是支持的。為了實(shí)現(xiàn)用戶對瀏覽器的絕對控制,ie中用close關(guān)閉非 open打開的窗口時(shí)會彈出一個(gè)對話框詢問用戶。有時(shí)候我們不希望再這樣哆嗦,但是怎么去掉這個(gè)框呢,請看下面的代碼。 function winClose(){ window.top.opener = null; window.close(); } 在window.close之前加上window.top.opener = null就可以了。 不過,把上面的代碼用來試一下的話,我們會發(fā)現(xiàn),在FireFox中好像沒起作用。會不會是firefox不支持 close,其實(shí)不然。之所以window.close在firefox不能使用,是因?yàn)閒irefox默認(rèn)不能關(guān)閉用戶打開的網(wǎng)頁,我們可以這樣設(shè)置 firefox: 打開firefox,在地址欄輸入about:config 找到dom.allow_scripts_to_close_windows這項(xiàng)并改為true。 再把上面的代碼用來試一下吧! |
|
|