在javascript中控制浏览器窗口关闭 [英] Control the browser window close in javascript

查看:102
本文介绍了在javascript中控制浏览器窗口关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我不想用javascript关闭浏览器窗口,是否可以这样做?我需要控制浏览器关闭窗口。

问候,

mageswaran

hello guys,
I dont want to close the browser window using javascript, is it possible to do this? i need to control the browser close window.
regards,
mageswaran

推荐答案

你可以使用onbeforeunload where支持,但明智地使用。注意,它也会在返回/前进或重新加载时触发。
You can use onbeforeunload where supported, but use wisely. Note that it will also fire when going back/forward or reloading.


你好先生,

i使用onbeforeunload函数,它工作正常,它可以控制浏览器

只关闭,但我还需要控制Alt + F4。如果我使用Alt + F4关闭意味着浏览器应该关闭,请给我编码和一些想法。

问候,

Mageswaran
hello sir,
i use onbeforeunload function, its working fine, it can control the browser
close only, but i need to control Alt + F4 also . If i use Alt + F4 to close means the browser should be closed, please give me the coding and some idea.
Regards,
Mageswaran

所以你不想在按下Alt-F4时触发onb​​eforeunload吗?
So you don''t want the onbeforeunload to fire when Alt-F4 is pressed?


这篇关于在javascript中控制浏览器窗口关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆