Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1038 Is there a way for a popup window to check if the URL of the main window has changed to a URL on a different server without causing an error?

irt.org | Knowledge Base | JavaScript | Window | Q1038 [ previous next ]

Q1038 Is there a way for a popup window to check if the URL of the main window has changed to a URL on a different server without causing an error?

You should be able to do this with an image.

If in you opener window you defined an image using:

<script language="JavaScript"><!--
if (document.images)
    var myUniqueReference = new Image();
//--></script>

Then in the popup window you should be able to detect this using:

<script language="JavaScript"><!--
if (opener.myUniqueReference ? true : false)
    alert('My window');
else
    alert('Not my window');
//--></script>

This should work even if the opener now contains a document from another server.


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 6th July 2009. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2009 irt.org, All Rights Reserved.