如何在Mozilla Firefox 3上使用Javascript关闭窗口? [英] How can I close a window with Javascript on Mozilla Firefox 3?
问题描述
我需要关闭显示我的网页的标签,只需点击一下按钮。但是,Firefox不允许通过javascript关闭窗口,只要它不是由JavaScript打开。
如果将 dom.allow_scripts_to_close_windows
的值设置为true,那么即使正常 window.close()
也可以。但这不是一个好的解决方案。 :(b / b)
我在下面的论坛中尝试了以下解决方法:
$ p $ <$ c
function closeWindow(){
window.open('','_ parent',''); $ b $> $ c>< script language =javascripttype =text / javascript> $ b window.close();
}
< / script>
它应该欺骗浏览器,认为它实际上是由javascript打开的,但这在Firefox 3中不起作用。
任何人都可以提出一个解决方法吗? / p>
function closeWindow(){
netscape.security.PrivilegeManager.enablePrivilege ;
alert(This will close the window);
window.open('','_ self');
window.close();
}
closeWindow();
I need to close the tab which displays my webpage, by the click of a button. But firefox does not allow to close the window by javascript as long as it is not opened by javascript.
If I set the value of dom.allow_scripts_to_close_windows
to be "true", then even normal window.close()
works too. But that is not a good solution. :(
I tried the following workaround suggested in one of the forums:
<script language="javascript" type="text/javascript">
function closeWindow() {
window.open('','_parent','');
window.close();
}
</script>
It is supposed to fool the browser into thinking that it was actually opened by javascript, but this does not work in Firefox 3.
Can anyone please suggest a workaround?
function closeWindow() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
alert("This will close the window");
window.open('','_self');
window.close();
}
closeWindow();
这篇关于如何在Mozilla Firefox 3上使用Javascript关闭窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!