Re: Disabling the close button



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
.


Quantcast