khuffenb
01-07-2004, 05:30 AM
I am trying to set the onunload event handler of one frame from another. It only works with local files, and not with outside websites, even when I request enhanced privileges.
Example follows:
frameset.html:
<html>
<frameset cols="10%,*" frameborder="1">
<frame name="leftframe" src="left.html">
<frame name="rightframe" src="http://google.com">
</frameset>
</html>
left.html:
<html>
<script>
function unloading() {
alert("unloading!");
}
function set_onunload() {
try{
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
parent.rightframe.onunload = unloading;
}
catch(e){
alert("Error : Can't set onunload!");
}
}
</script>
<a href="left.html" onClick="javascript:set_onunload()">Set onunload!</a>
</html>
If the external url in the righthand frame is replaced with a local file, the script works correctly, displaying the alert when the right hand frame unloads. With a nonlocal file though, the frame does not show an alert when unloading.
I'm using Mozilla 1.2.1.
Any guidance would be greatly appreciated.
Example follows:
frameset.html:
<html>
<frameset cols="10%,*" frameborder="1">
<frame name="leftframe" src="left.html">
<frame name="rightframe" src="http://google.com">
</frameset>
</html>
left.html:
<html>
<script>
function unloading() {
alert("unloading!");
}
function set_onunload() {
try{
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
parent.rightframe.onunload = unloading;
}
catch(e){
alert("Error : Can't set onunload!");
}
}
</script>
<a href="left.html" onClick="javascript:set_onunload()">Set onunload!</a>
</html>
If the external url in the righthand frame is replaced with a local file, the script works correctly, displaying the alert when the right hand frame unloads. With a nonlocal file though, the frame does not show an alert when unloading.
I'm using Mozilla 1.2.1.
Any guidance would be greatly appreciated.