0

Hello I have iframe and in the iframe i need to get element of the parent window. How can i do it ?

    index.html

child.html get parent element by id

usmauriga
  • 73
  • 1
  • 1
  • 5
  • Possible duplicate of [Getting parents document from iFrame](http://stackoverflow.com/questions/8066547/getting-parents-document-from-iframe) and http://stackoverflow.com/questions/7027799/access-elements-of-parent-window-from-iframe – Turnip May 07 '16 at 13:19

1 Answers1

1

If you have var myVar in the parent window, you can access it from the child window with window.parent.myVar.

Note: this will only work if both child and parent are on the same domain.

See here for more info.

I wrestled a bear once.
  • 22,983
  • 19
  • 69
  • 116