1

lets say we have an iframe in page test1.html

<iframe src=test2.html"></iframe>

and there is a link in test2.html:

<a href="test3.html" target="_blank">open in new window"</a>

in test3.html how can I know the parent of the opener? (that is test1.html)

Ashkan Mobayen Khiabani
  • 33,575
  • 33
  • 102
  • 171

1 Answers1

4

Something like window.opener.top should get you the window object of the parent. From there you can get .location.href, or whatever you need. Keep in mind that browser restrictions will cause this to fail if any of the documents are on different domains.

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592