> You may use javascript function attachEvent:
>
[quoted text clipped - 12 lines]
>
> http://www.logicwebsolutions.com
Perhaps just the following?
<html>
<head>
<title>closer.htm</title>
<script type="text/javascript">
function closer() {
alert("This window is about to close.");
}
</script>
</head>
<body onbeforeunload="closer()">
</body>
</html>
James - 29 Nov 2005 19:30 GMT
If you do not have other functions to handle this event you approch is
fine.
BTW, you shoud use return instead of alert; by using return, the page
will stay
if the user clicks Cancel button from the popup window.
James
http://www.logicwebsolutions.com
Thomas 'PointedEars' Lahn - 29 Nov 2005 20:34 GMT
> "James" <james_fjz@yahoo.com> wrote [...]:
>> You may use javascript function attachEvent:
[quoted text clipped - 25 lines]
> </body>
> </html>
In contrast to your solution, James', even though it has its bugs, allows
the user to cancel the unload-Event in IE an Mozilla/5.0 if corrected (and
it does not make a successful attempt in providing invalid HTML). However,
I am not sure whether selecting "Cancel" would also prevent closing the
window.
PointedEars
> You may use javascript function attachEvent:
attachEvent is neither a JavaScript nor a JScript function.
It is a method of the IE(4?) DOM.
<URL:http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/attachevent.asp>
> function window.onload()
-----------------^
SyntaxError: missing ( before formal parameters
> If you think the anwser helps you, please show your support by visiting
> my website:
YMMD!
PointedEars
James said the following on 11/29/2005 1:25 PM:
Please quote what you are replying to.
If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.
> You may use javascript function attachEvent:
>
[quoted text clipped - 7 lines]
> return 'Are you sure you want to close my lovely window?'
> }
That does absolutely nothing to stop me from closing the browser. In
fact, it only makes me *more* determined to leave your site. I am
leaving, let me go in Peace.
> If you think the anwser helps you, please show your support by visiting
> my website:
I hope your website has better advice than you give here.
For example, does it explain that in Usenet you should quote what you
are replying to?

Signature
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
lightzizo - 30 Nov 2005 08:23 GMT
Hello all
thanks for your replies
but actually I want to describe the situation here:
I'm opening a popup window from another popup and i don't want the user
to close the parent popup as long as the child is still opened.
I've thought about making the child to be modal screen but how can i do
that??
> James said the following on 11/29/2005 1:25 PM:
>
[quoted text clipped - 33 lines]
> comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
> Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Thomas 'PointedEars' Lahn - 30 Nov 2005 12:26 GMT
> I'm opening a popup window from another popup and i don't want the
> user to close the parent popup as long as the child is still opened.
> I've thought about making the child to be modal screen but how can
> i do that??
You do not, that would only make your app less interoperable (IE only).
Returning a string to onbeforeunload is probably the best approach
here. Let the user decide whether or not the window should be closed.
> [top post]
<URL:http://jibbering.com/faq/faq_notes/pots1.html#ps1Post>
PointedEars
James - 30 Nov 2005 17:38 GMT
Use JavaScript function:
window.showModalDialog
Thomas 'PointedEars' Lahn - 30 Nov 2005 17:45 GMT
> Use JavaScript function:
>
> window.showModalDialog
which is not a JavaScript function and is IE-only, so don't.
PointedEars