Re: Disabling the close button
- From: Thomas 'PointedEars' Lahn <PointedEars@xxxxxx>
- Date: Tue, 29 Nov 2005 21:34:51 +0100
McKirahan wrote:
> "James" <james_fjz@xxxxxxxxx> wrote [...]:
>> You may use javascript function attachEvent:
>>
>> function window.onload()
>> {
>> window.attachEvent("onbeforeunload", Close);
>> }
>>
>> function Close()
>> {
>> return 'Are you sure you want to close my lovely window?'
>> }
>>
>> [...]
>
> 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>
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
.
- References:
- Disabling the close button
- From: lightzizo
- Re: Disabling the close button
- From: James
- Re: Disabling the close button
- From: McKirahan
- Disabling the close button
- Prev by Date: Re: Disabling the close button
- Next by Date: Re: Calling server-side function from client javascript
- Previous by thread: Re: Disabling the close button
- Next by thread: Re: Disabling the close button
- Index(es):