[英]Javascript 'onunload' event not working in latest Version '54.0.2840.71 m' of Google Chrome browser
最近,我將Google Chrome瀏覽器更新為版本“ 54.0.2840.71 m”,然后突然出現了JavaScript“ onUnload”事件停止工作。 我敢肯定,升級之前它運行良好。
在我的代碼(如下所述)中,我試圖從“父”窗口中打開“子”窗口,並且當子窗口關閉/刷新時(即,觸發其卸載事件時),它也應該重新加載或刷新父窗口。
parent.html文件的源代碼:
<!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文件的源代碼:
<!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”瀏覽器中均能正常運行,並且還曾經在“ Google Chrome”的較早版本中起作用,而在最新版本中則無效。
如果我做錯了事,請告訴我。
感謝和問候!
我猜想該事件實際上是被調用的(因為我可以添加斷點並在其中做任何其他事情),並且此提交只是忽略了該window.opener.location.reload(): https:// chromium.googlesource.com/chromium/src/+/8fb70277dba468aac9d2eae51e432d76667a79db
我也創建了一個錯誤( https://bugs.chromium.org/p/chromium/issues/detail?id=660496 ),因為您擔心由於前面提到的差異而導致您的錯誤被關閉。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.