Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1716 How can I detect when the opener of a popup window has changed?

You are here: irt.org | FAQ | JavaScript | Window | Q1716 [ previous next ]

Try the following, which might work even when the opener window has loaded a page from a different domain:

<html>

<head>

<script language="JavaScript"><!--
var originalName = window.name;
window.name = (new Date()).getTime();

var windowReference = window.open('test.htm?' + name,'windowName','width=640,height=480');
//--></script>

</head>

<body onUnload="window.name=originalName">

<a href="about:blank" onClick="window.name=originalName">Change location of opener window</a>

</body>

</html>

And then in test.htm:

<html>

<head>

<script language="JavaScript"><!--
var time = '';
if (location.search.length > 1)
  time = location.search.substring(1);
//--></script>

</head>

<body>

<form>
<input type="button" onClick="if (time != opener.name) alert('changed')" value="opener?">
</form>

</body>

</html>

©2018 Martin Webb