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

Q1111 How can I tell from one frame when another frame's url changes and have it act accordingly?

irt.org | Knowledge Base | JavaScript | Frame | Q1111 [ previous next ]

Q1111 How can I tell from one frame when another frame's url changes and have it act accordingly?

Only if the url in the other frame comes form the same server as the page that 'snoops' - otherwise a security error occurs.

Have this in the frameset:

<html>
<head>

<script language="JavaScript"><!--
saveUrl = '';

function hasChanged() {
    var currentUrl = top.otherframe.location.href;
    if (currentUrl != top.saveUrl && top.saveUrl != '') {
        alert('Page changed from ' + saveUrl + '\nto ' + currentUrl);
    }
    saveUrl = currentUrl;
    setTimeout('top.hasChanged()',10000); // test every 10 seconds
}
//--></script>
</head>

<frameset onLoad ="top.hasChanged()">
...
</frameset>

The script can also be in one frame, then "top." must be changed to "top.framename." everywhere but the onLoad stays unchanged.

Feedback on 'Q1111 How can I tell from one frame when another frame's url changes and have it act accordingly?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


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