There is a site, there is an iframe in it, into which another site is loaded. I want to highlight BODY green, when another site is fully loaded into the iframe , and to output an alert when the location iframe 'a changes from default (predefined) to some other.

How to do it?

1 answer 1

The iframe element is a regular DOM node, just like any other. The essential difference is that the window object of the inner window is associated with it. It is available via the iframe.contentWindow link.

Thus, iframe.contentWindow.document will be an internal document, iframe.contentWindow.document.body - its and so on.

https://learn.javascript.ru/iframes

  • "For example, to find out about the end of the load <iframe>, we can hang up the iframe.onload handler. In fact, this is the same as iframe.contentWindow.onload, but we can deliver it only if the window is from the same source. " learn.javascript.ru/… - Sublihim