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

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

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

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

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?'


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.