By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,379 Members | 1,748 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,379 IT Pros & Developers. It's quick & easy.

confirm closing web page

P: n/a
I've this problem.
I need, when the user close the web page, to show a message of confirm with
Ok and cancel.
With the event unload when I click cancel the web page closes however.
What can I do ?
Sorry for the bad English.
Hello.
Jul 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
I found,
thanks

<SCRIPT LANGUAGE="JavaScript" EVENT="onbeforeunload()" FOR="window">
event.returnValue = "Chiudi questa finestra ! Sei sicuro?";
</SCRIPT>
"Fabrizio" <fa*************@atenait.it> ha scritto nel messaggio
news:7q**********************@twister1.libero.it.. .
I've this problem.
I need, when the user close the web page, to show a message of confirm with Ok and cancel.
With the event unload when I click cancel the web page closes however.
What can I do ?
Sorry for the bad English.
Hello.

Jul 20 '05 #2

P: n/a
I think that onbeforeunload() event will only work with IE!

But not sure on that info...anybody!??

Respect...

p.

"Fabrizio" <fa*************@atenait.it> wrote in message
news:DN**********************@twister2.libero.it.. .
I found,
thanks

<SCRIPT LANGUAGE="JavaScript" EVENT="onbeforeunload()" FOR="window">
event.returnValue = "Chiudi questa finestra ! Sei sicuro?";
</SCRIPT>
"Fabrizio" <fa*************@atenait.it> ha scritto nel messaggio
news:7q**********************@twister1.libero.it.. .
I've this problem.
I need, when the user close the web page, to show a message of confirm

with
Ok and cancel.
With the event unload when I click cancel the web page closes however.
What can I do ?
Sorry for the bad English.
Hello.


Jul 20 '05 #3

P: n/a
If you want to manually control the close via a link on your page then just
write a function that will do that.

function confirmClose() {
if (confirm("Are you sure that you want to close this window?")) {
top.close();
//or self.close();
}
}

If you want to capture a user clicking on the close icon in the top right of
a browser such as IE or NetScape, then I don't know how you would capture
this via JavaScript.

Peter.
"point" <in**@caanproduction.com> wrote in message
news:be*********@enews2.newsguy.com...
I think that onbeforeunload() event will only work with IE!

But not sure on that info...anybody!??

Respect...

p.

"Fabrizio" <fa*************@atenait.it> wrote in message
news:DN**********************@twister2.libero.it.. .
I found,
thanks

<SCRIPT LANGUAGE="JavaScript" EVENT="onbeforeunload()" FOR="window">
event.returnValue = "Chiudi questa finestra ! Sei sicuro?";
</SCRIPT>
"Fabrizio" <fa*************@atenait.it> ha scritto nel messaggio
news:7q**********************@twister1.libero.it.. .
I've this problem.
I need, when the user close the web page, to show a message of confirm

with
Ok and cancel.
With the event unload when I click cancel the web page closes however.
What can I do ?
Sorry for the bad English.
Hello.



Jul 20 '05 #4

P: n/a
In article <lU*******************@newsfep1-win.server.ntli.net>, "ManoDestra"
<ma*****************@ntlworld.com> writes:
If you want to capture a user clicking on the close icon in the top right of
a browser such as IE or NetScape, then I don't know how you would capture
this via JavaScript.


Post
Top
Dont
Please

You can't detect how I left a page other than your mentioned script. Other than
that, you have no way of knowing if I closed the browser, clicked a favorite,
typed a URL in, only that I left.
--
Randy
All code posted is dependent upon the viewing browser
supporting the methods called, and Javascript being enabled.
Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.