是否可以使用javascript关闭浏览器窗口?

编程入门 行业动态 更新时间:2024-10-28 21:23:04
本文介绍了是否可以使用javascript关闭浏览器窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要使用java脚本关闭浏览器窗口。

I need to close the browser window using the java script.

我尝试过使用window.close但它无效。

I have tried using window.close but it is not working.

我也搜索并检查了任何类似帖子的堆栈溢出。我也经历过以下链接,但徒劳无功。

I have also googled and checked stack overflow for any similar posts. I have also gone through following link but in vain.

是否可以从JavaScript关闭浏览器窗口?

我要做的是加载一个页面和页面加载调用一个java脚本方法,它执行window.close

What I am trying to do is load a page and on load of the page call a java script method which does window.close

下面是代码

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <script> function closeBrowser(){ window.close(); } </script> </head> <body onload="closeBrowser();"> </body> </html>

虽然它在IE8中正常工作。它不在火狐中工作。

It is properly working in IE8 though. Its not working in the fire fox.

即使在IE中,它也会在实际关闭浏览器之前提供警报提示。我们可以避免在IE中发出警报吗?

And even in IE it gives the alert prompt before actually closing the browser. Can we avoid the alert in IE?

为什么它在火狐中不起作用?

Why it does not work in fire fox?

推荐答案

它不在火狐中工作的原因是由于火狐的某些设置。

The reason it was not working in fire fox was due to some settings in the fire fox.

请设置你的firefox浏览器:

Please set your firefox browser:

1.输入about:config到你的firefox地址栏和输入;

1.input "about:config " to your firefox address bar and enter;

2.确保你的dom.allow_scripts_to_close_windows为真

2.make sure your "dom.allow_scripts_to_close_windows" is true

window.close现在正在工作在火狐中也是如此。

window.close is now working in fire fox too.

更多推荐

是否可以使用javascript关闭浏览器窗口?

本文发布于:2023-05-27 09:55:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/285718.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:可以使用   关闭浏览器   窗口   javascript

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!