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

Q1056 How can I monitor one frame from another and detect when the contents have changed?

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

Q1056 How can I monitor one frame from another and detect when the contents have changed?

Try the following, which will work so long as the pages are all on the same server:

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript"><!--
var lastUrl = '';

function monitor() {
    if (lastUrl != windowFrameNameToMonitor.location.href) {
        alert('Changed from: ' + lastUrl + ' to: ' + windowFrameNameToMonitor.location.href);
        lastUrl = windowFrameNameToMonitor.location.href;
    }
    setTimeout('monitor()',1000);
}

function startToMonitor() {
    lastUrl = windowFrameNameToMonitor.location.href;
    setTimeout('monitor()',1000);
    alert(lastUrl);
}
//--></SCRIPT>
</HEAD>

<FRAMESET ROWS="50%,*" onLoad="startToMonitor()">
<FRAME SRC="test1.htm">
<FRAME SRC="test2.htm" NAME="windowFrameNameToMonitor">
</FRAMESET>
</HTML>

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.