简体   繁体   中英

Internet Explorer Iframe recursive window.onblur

I have a funny problem that I need to solve. In short the Internet Explorer uses the window.onblur event to focus an element in an iFrame. Because of that it's a recursion and you cannot click anything outside of the iFrame. Problem occurs in IE9, IE10, IE11 (not IE8 and below).

Test it here: Try it (in IE)

Download it here: Download it

My real question is: Is there a way to overwrite the window.onblur event inside the iFrame from outside the iFrame? Is this a Bug and should I report this somewhere to Microsoft?

Update

Thanks for your help @Jonathan Sampson, this works as can be seen here:

See working example - you must wait until IFrame is fully loaded to be able to overwrite it

I work on the Internet Explorer team and will gladly look into this for you. To answer your question about overwriting the onblur handler in the iframe, this is possible if the two documents share a common domain. In your example, this is the case.

document.querySelector( "iframe" ).contentWindow.onblur = null;

Alternatively, you may only want to bind to the highest window using window.top .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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