Read parent document from iFrame and change parent document

I am trying to write a JavaScript application that will load a button in an iFrame on the page. This application will read the parent document and cross out all the images, apply a minimal style and reload the parent with this new marked page.

The problem I encountered is reading and writing the parent document from the iFrame. Does anyone know how to achieve this? I read a little about cross-domain messaging, but am not sure about the alternatives, and what would be better.

Thanks in advance.

+5
source share
1 answer

, , .

  • parent ==
  • top == out most window

, div

var d = parent.document.getElementByTagName("div")[0];

, , iframe , .

+13

All Articles