[英]How can i override the windows.onbeforeunload function only for an iframe?
I have an eventlistener我有一个事件监听器
window.onbeforeunload=function(evt){
//causes pop up
}
I need to override it with another event listener for an iframe(Download case here).我需要使用 iframe 的另一个事件侦听器覆盖它(在此处下载案例)。 The below code is not working
下面的代码不起作用
var tIFrame = document.getElementById('Download');
iFrame.contentWindow.addEventListener('beforeunload', wrappedFn, false);
iFrame.addEventListener('beforeunload', wrappedFn, true); iFrame.addEventListener('beforeunload',wrappedFn,true);
Thanks @Bergi for the hint.感谢@Bergi 的提示。 The below code worked for me
下面的代码对我有用
var iFrame=document.getElementById('Download');
iFrame.contentWindow.onbeforeunload=function(){}
iFrame.contentWindow.location.href=sCmd;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.