Javascript'onunload'活动在最新版本'54 .0.2840.71 m'的Google Chrome浏览器中无效 [英] Javascript 'onunload' event not working in latest Version '54.0.2840.71 m' of Google Chrome browser

查看:153
本文介绍了Javascript'onunload'活动在最新版本'54 .0.2840.71 m'的Google Chrome浏览器中无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我将我的Google Chrome浏览器更新为版本'54 .0.2840.71 m',突然javascript'onUnload'事件已停止工作。我确信,它在升级之前工作正常。

Recently I updated my Google Chrome browser to Version '54.0.2840.71 m' and suddenly javascript 'onUnload' event has stopped working. I am sure, it was working fine before the upgrade.

在我的代码(如下所述)中,我试图从'Parent'打开一个'Child'窗口窗口和子窗口关闭/刷新时(即触发其卸载事件时),它还应重新加载或刷新父窗口。

In my code (mentioned below), I am trying to open a 'Child' window from a 'Parent' window and when the child window is closed/refreshed (i.e. when its unload event is triggered), it should also reload or refresh the parent window.

父窗口的源代码。 html文件:

Source code of parent.html file:

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Parent Page</title>
    </head>
    <body>
        This is parent page. Click <a href="#" onClick="window.open('child.html', '_blank', 'toolbar=no,scrollbars=yes,resizable=no,top=150,left=250,width=500,height=500'); return false;">here</a> to open the child page.
    </body>
</html>

child.html文件的源代码:

Source Code of child.html file:

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Child Page</title>
        <script type="text/javascript">
            window.onunload = refreshParent;
            function refreshParent() {
                window.opener.location.reload();
            }
        </script>
    </head> 
    <body>
        This is child page.
    </body>
</html>

此代码在Internet Explorer和Mozilla Firefox浏览器中都能正常运行,它也曾用于在早期版本的谷歌浏览器中工作但不是最新版本。

This code works properly in both 'Internet Explorer' and 'Mozilla Firefox' browsers and it also used to work in earlier version of 'Google Chrome' but not its latest version.

如果我做错了,请告诉我。

Please let me know if I am doing something incorrectly.

谢谢&问候!

推荐答案

我猜这个事件实际上是被调用的(因为我可以添加断点并执行其他任何操作)这个提交正在忽略/阻止window.opener.location.reload(): https://chromium.googlesource.com/chromium/src/+/8fb70277dba468aac9d2eae51e432d76667a79db

I'm guessing that the event is actually called (as I can add breakpoints and do just about anything else in it) and that window.opener.location.reload() is just being ignored / prevented by this commit: https://chromium.googlesource.com/chromium/src/+/8fb70277dba468aac9d2eae51e432d76667a79db

我也创建了一个错误( https://bugs.chromium.org/p/chromium/issues/detail?id= 660496 )由于前面提到的差异,我担心您的错误会被关闭。

I've created a bug as well (https://bugs.chromium.org/p/chromium/issues/detail?id=660496) as I'm afraid your bug will be closed due to the previously mentioned discrepancy.

这篇关于Javascript'onunload'活动在最新版本'54 .0.2840.71 m'的Google Chrome浏览器中无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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