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

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

You are here: irt.org | FAQ | JavaScript | Frame | Q1056 [ previous next ]

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>

©2018 Martin Webb