Jone schreef:
Hello All,
Hi
Has anyone of you a working sample how to code an UnLoad method out of
body tag with javascript?
Yes, it is simple: just add the eventhandler to the body or document.
I have a common problem where a javascript function should be called
after a certain window is closed. I can't add javascript to window's body
tag because it's a third party code.
That might be more difficult.
Your 'parentdocument' (opener from the perspective of the just opened
page) cannot modify the newly opened window (since you said it is third
party, probably meaning other domain???).
So a working sample in IE and Firefox would be great,
You can however try this:
- from the opener query the newly opened window for its property 'closed'.
Here is an example.
<script type="text/javascript">
var myWinRef;
function openWin(){
myWinRef = window.open("
http://www.google.com","winname");
startPolling();
}
function startPolling(){
document.forms.testform.output.value="myWinRef['closed']="+myWinRef['closed'];
window.setTimeout("startPolling();",1000); }
</script>
<form action="" name="testform">
<input type="button" onClick="openWin();" value="Click me open new window
and try to add eventhandler">
<input type="text" name="output" size="60">
</form>
You will see the text in the field 'output' will change from false to true
when you close the new window.
This will work in FF3 and IE7. I have no clue which other browsers support
this 'closed' property... You'll have to find that out yourself.
Regards,
Erwin Moller
--
"There are two ways of constructing a software design: One way is to make
it so simple that there are obviously no deficiencies, and the other way
is to make it so complicated that there are no obvious deficiencies. The
first method is far more difficult."
-- C.A.R. Hoare