Created
July 25, 2021 07:02
-
-
Save hoangitk/5daedfa83d6d993a71c06410eb0fce2a to your computer and use it in GitHub Desktop.
[Get Iframe Window] #javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getIframeWindow(iframe_object) { | |
var doc; | |
if (iframe_object.contentWindow) { | |
return iframe_object.contentWindow; | |
} | |
if (iframe_object.window) { | |
return iframe_object.window; | |
} | |
if (!doc && iframe_object.contentDocument) { | |
doc = iframe_object.contentDocument; | |
} | |
if (!doc && iframe_object.document) { | |
doc = iframe_object.document; | |
} | |
if (doc && doc.defaultView) { | |
return doc.defaultView; | |
} | |
if (doc && doc.parentWindow) { | |
return doc.parentWindow; | |
} | |
return undefined; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment