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

Q971 Is there any way to monitor the contents of a frame, and detect when the location has changed?

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

If the pages are your pages, i.e. all on the same server, then you could monitor the other frame using:

In the frameset page:

<html>
<head>
<script language="JavaScript"><!--
var lastUrl = '';

function doSomething() {
    // do something
}

function monitor() {
    if (lastUrl != window.frame1.location.href) {
        lastUrl = window.frame1.location.href);
        doSomething();
    }
    setTimeout('monitor()',1000);

}

function startToMonitor() {
    lastUrl = window.frame1.location.href;
}
//--></script>
</head>

<frameset rows="50%,*" onLoad="startToMonitor()">
<frame src="page1.htm" name="frame0">
<frame src="page2.htm" name="frame1">
</frameset>
</html>

Feedback on 'Q971 Is there any way to monitor the contents of a frame, and detect when the location has changed?'

©2018 Martin Webb