Accessing an iframe document (contentWindow) - JavaScript Tutorial

preview_player
Показать описание
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:

For your reference, check this out:

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!

#dcode #javascript #webdev
Рекомендации по теме
Комментарии
Автор

*RELATED VIDEO: SEND DATA BETWEEN TABS IN JAVASCRIPT*

🏷 *THE ULTIMATE JAVASCRIPT DOM CRASH COURSE* 👇

dcode-software
Автор

Thank you!!! You helped me figure something out I was working on for four hours. This enabled me to understand multiple codes I was working with. Thank you!

christianhelwig
Автор

This is for the Same-origin Iframe only... You can't access iframe from the different domain using the method explained in this video

TECHINSPEC
Автор

I like the typing sound effects. Sounds real af

heatvisuals
Автор

What if the origin of the iframe is at a different origin, i.e. not local to the page? Is something similar possible that yeilds the same outcomes?

Tmmy
Автор

You are the best javascript programmer in the world. Thank you very much 🌹

omarzaky
Автор

Meu amigo gringo, muito obrigado! Sua solução é simples e fácil de implantar. Parabéns!

leopoldosantiago
Автор

This example shows that will only work for local pages however if you link the iframe to another link it will be dom exception for x-frame error

hessiride
Автор

This channel has solution for almost every problem

newcomer
Автор

This is ok, when pages are from same source, but how to do that if we embed in iframe some other website? Can we manipulating with objects of that?

valentinagajic
Автор

I have one question about Iframe: I displayed an external website in my angular project, inside external website I have a link to open pdf. if I click on that link, it will be opened in a new tab. I want to open it inside the iframe. how can I do that. I would be very happy hearing back from you thanks

murtazamohammadi
Автор

Thank you for this great video. Can you post a version with an onload-execution? As soon as the script is loaded, some JS-code should be executed.

wowwwww
Автор

But what can I do this if the iframe component is comming from another origin

nishilsuthar
Автор

how do i change the file inside an iframe to another at runtime

stig
Автор

How to insert a script within a head tag of an iFrame if the iFrame has no id attributes?

abusalahamusazangi
Автор

Hi, please could you do a video showing how to use Javascript to change content inside iframe every 5s? That would be very helpfull

vivianeasaraiva
Автор

I am a bit curious how to get the console content from this iframe and show it somewhere else in the web browser not in the developer tools

zqgAFf
Автор

*Question:*
How can I open external application (on mobile) using JavaScript (create open-in-app feature)?

thelostman
Автор

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.

vicente
Автор

Do I need the .css to make it run error free ?
const iframeDocument = myIframe.contentDocument;
Why does this statemment retern null ?:
console.log(iframeDocument) // ? = null
WHy does this starement give me this error:
Uncaught TypeError: Cannot read property 'querySelector' of null

= lightgreen ;
I have typed out your code many times, but it always gives errors .
Can I get a copy of the source code .
Thanks

vmars
visit shbcf.ru