In this video we take a look at the contentWindow and contentDocument properties of an embedded iframe – it allows access to the underlying “window” and “document” objects of the HTML page.
Support me on Patreon:
https://www.patreon.com/dcode – with enough funding I plan to develop a website of some sort with a new developer experience!
For your reference, check this out:
https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/contentWindow
Follow me on Twitter @dcode!
If this video helped you out and you’d like to see more, make sure to leave a like and subscribe to dcode!
Original source
10 responses to “Accessing an iframe document (contentWindow) – JavaScript Tutorial”
Can you post the source code somewhere?
Thanks! Is it also possible to pause and start an embedded video from youtube that is running in an iFrame?
Uncaught DOMException: Blocked a frame with origin "null" from accessing a cross-origin frame.
i get this error when i do a console.log(myIframe)
Hello, tnx for this video is very helpful. I just want to ask if is possible to do the same staff but with the button inside the iframe? for example i want to push the button and then close the do a z-index in order to hidde it.
Kind regards.
I like the typing sound effects. Sounds real af
I am getting below error while accessing the iframe with its id
SecurityError: Permission denied to access property "document" on cross-origin object
how to access cross-origin external website like google.com inside iframe. I am getting cross-origin error. Please help
Best one I found
Thanks it’s very helpful
Can you show how to use scrollHeight properties of an element?