Entry
How can I capture load events of frames in the frameset document?
How can I capture load events of frames in the frameset document?
How can I capture load events of frames in the frameset document?
Mar 25th, 2000 05:07
Martin Honnen,
First of all there is
<FRAMESET ONLOAD="alert(event.type)" ..."
which fires on the first load of the complete frameset after all frames
are loaded.
But often you might want to capture following load events when single
frames change.
With NN4 you can do so by calling
window.captureEvents(Event.LOAD);
window.onload = function (evt) {
if (evt.target.name == 'frameName')
// load for frame frameName
else if (evt.target.frame = 'otherFrameName')
...
};
Note that the above does only work for frames on the same server as the
capturing frameset. If you want to capture load events from remote
frames you need trusted script:
netscape.security.PrivilegeManager.enablePrivilege(
'UniversalBrowserWrite'
);
window.enableExternalCapture();
window.captureEvents(Event.LOAD);
window.onload = function (evt) {
if (evt.target.name == 'frameName')
// load for frame frameName
else if (evt.target.frame = 'otherFrameName')
...
};
Here is a complete example of a two frame frameset which protocols in
one frame the load events happening in the other frame:
<HTML>
<HEAD>
<SCRIPT>
var loaded = false;
netscape.security.PrivilegeManager.enablePrivilege
('UniversalBrowserWrite');
window.enableExternalCapture();
window.captureEvents(Event.LOAD);
window.onload = function (evt) {
if (evt.target == window)
loaded = true;
if (loaded && evt.target == main) {
var end = new Date();
var status = control.document.gui.status;
netscape.security.PrivilegeManager.enablePrivilege
('UniversalBrowserRead');
status.value += 'loaded ' + main.location.href + '\n';
status.value += ' loaded in ' + ((end - control.start) / 1000)
+ 'seconds.\n';
}
}
</SCRIPT>
</HEAD>
<FRAMESET ROWS="250, *">
<FRAME NAME="control" SRC="loadControl.html">
<FRAME NAME="main" SRC="about:blank">
</FRAMESET>
</HTML>
<HTML>
<HEAD>
<SCRIPT>
var start;
function loadURL (url) {
var status = document.gui.status;
document.gui.url.value = url;
status.value += 'loading ' + url + '...\n';
start = new Date();
parent.main.location.href = url;
}
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="gui">
select url to load:
<INPUT TYPE="button" VALUE="go"
ONCLICK="var url =
this.form.urlSelect.option[this.form.urlSelect.selectedIndex].value;
loadURL(url)"
>
<BR>
<SELECT NAME="urlSelect"
ONCHANGE="loadURL(this.options[this.selectedIndex].value)"
>
<OPTION VALUE="http://javascript.faqts.com">JavaScript.FAQTs
<OPTION VALUE="http://www.faqts.com">faqts
<OPTION VALUE="http://www.kibo.com">GOD
</SELECT>
<INPUT TYPE="text" NAME="url" SIZE="80"
ONCHANGE="loadURL(this.value);"
>
<BR>
<TEXTAREA NAME="status" ROWS="5" COLS="80" WRAP="soft">
</TEXTAREA>
</FORM>
</BODY>
</HTML>
AFAIK there is no comparable feature in IE to capture load events for a
frame from a frameset.