如何在Mozilla中使用javascript关闭弹出窗口 [英] how to close the pop up window using javascript in mozilla
问题描述
function ModalPopupsPromptOk() {
window.open("", "_self", "")
window.close();
正在使用上述代码关闭弹出窗口,它在google chrome,safari和IE中运行良好,但在无法正常工作的mozilla firefox中,请让我建议替代方法
am using above mentioned code to close the pop up, its working well in the google chrome, safari, and IE but in mozilla firefox which is not working please let me suggest the alternative
推荐答案
只需检查该线程
http://stackoverflow.com/Questions/760422/how-can-i-close-a-window-with-javascript-on-mozilla-firefox-3 [
Just check this thread
http://stackoverflow.com/questions/760422/how-can-i-close-a-window-with-javascript-on-mozilla-firefox-3[^]
我使用了脚本
I used the script
<script type = "text/javascript">
function closeWindow(){
window.open('','_self','');
window.close();
}
</script>
这适用于IE(覆盖提示)和chrome,但不适用于Firefox,因为默认情况下,Firefox不允许使用JavaScript关闭标签页
需要在Firefox中执行以下步骤
1.转到地址栏,然后键入about:config
2.转到参数dom.allow_scripts_to_close_windows
3.将其值设置为true
this works well with IE (it overrides prompt) and chrome but is not working with Firefox as by default Firefox don''t allow to close tab using JavaScript
It is needed to follow these steps in Firefox
1. Go to address bar and type about:config
2. Go to parameter dom.allow_scripts_to_close_windows
3. Set its value as true
这篇关于如何在Mozilla中使用javascript关闭弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!