简体   繁体   English

window.onbeforeunload()在Firefox浏览器上不起作用关闭

[英]window.onbeforeunload() is not working on Firefox browser close

window.onbeforeunload() is working on browser close of IE and Chrome, but it is not working in case of Firefox(Works only on tab close) browser close. window.onbeforeunload()在IE和Chrome浏览器关闭时有效,但在Firefox(仅在选项卡关闭时有效)浏览器关闭的情况下不起作用。

My Requirement:: I am capturing mobile number, email id, Firstname and lastName etc.. using document.getelementById() and calling a service upon closing browser or tab. 我的要求::我正在使用document.getelementById()捕获手机号码,电子邮件ID,名字和姓氏等。并在关闭浏览器或选项卡时调用服务。

Problem : Service is getting called in case of IE and GC(tab/browser close) but not in case of FireFox. 问题:在IE和GC(选项卡/浏览器关闭)的情况下将调用服务,而在FireFox情况下则不会。

Any help is substantially appreciated...... 任何帮助表示赞赏...

  1. Check if you are returning a string or not. 检查是否返回字符串。

The function should assign a string value to the returnValue property of the Event object and return the same string. 该函数应为事件对象的returnValue属性分配一个字符串值,并返回相同的字符串。

2. It is advised to use onunload instead of onbeforeunload as the latter is often reported to work inconsistently and Mozilla's docs also indicate variation in implementation of the standard the event by browsers. 2.建议使用onunload代替onbeforeunload因为据报道后者通常工作不一致,并且Mozilla的文档还表明浏览器对事件标准的实现有所不同。 Although,IMO unload events are not really reliable and one should ignore them when can. 虽然,IMO卸载事件并不是真正可靠的,应该尽可能忽略它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM