onunload Ajax 函数在 Chrome 中不起作用
我正在开发一个应用程序,当用户离开页面时,需要将更新的数据存储在数据库中。为此,我将 Ajax 函数绑定到页面的“onunload”事件。这适用于除 Chrome 之外的所有浏览器。我也尝试过“onbeforeunload”,但结果是一样的。
我怀疑这与 Chrome 对其安全性过于热衷有关。当尝试测试该事件时,我发现它阻止了我放入的警报,以查看函数是否被调用,并且还收到错误“Usafe JavaScript 尝试使用 URL 访问框架...域、协议和端口必须匹配”。回发将转到同一域内的页面。
任何人都可以阐明这一点或可能为我提供解决方法吗?
I am developing an app that needs to store updated data in a database when the user leaves the page. To do this I have bound a Ajax function to the "onunload" event of the page. This works in every browser except Chrome. I have also tried "onbeforeunload" but the result is the same.
I suspect it something to do with Chrome being over zealous in it's security. When trying to test the event I found it was blocking the alerts I put in to see if function was even being called and also get the error "Usafe JavaScript attempt to access frame with URL ... Domains, protocols and ports must match." The postback is going to a page within the same domain.
Can anyone shed any light on this or possibly provide me with a work around?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅:http://code.google.com/p/chromium/issues /detail?id=4422
See: http://code.google.com/p/chromium/issues/detail?id=4422