Browser Close Problem

G

Guest

Dear All,

I have a Main Asp.Net page . In that Page I have a Tab Strip which has
SIX tabs each representing a different web Forms.So that when a user
clicks different tab he can navigate between different forms.In my Main
Page I have written a javascript code

function ConfirmClose() {

confirm("Are you Sure You Want to Close This Main Window?") ;

}

and in the body tag of Main form I have written <body onbeforeunload
="ConfirmClose()" >
Now this code is only for the Main Form which has a Tab Strip of SIX
different forms. Now the problem is When the Main Page is loaded
and I click X button of the browser It displays the message
("Are you Sure You Want to Close This Main Window?") which is
fine, but when I navigate to some other Form which is within the
MAIN FORM by pressing the Tab button the above message again
pops up.and it keeps poping up as I navigate through the six forms.
which I dont want. I only want this message to appear when I press
X Button of Main Browser window .

Any help much appreciated.

cheers,
Sunil Sabir
 
P

Patrice

See the documentation for the onclose event (I believe, check aslo brower
support).

onbeforeunlaod is when the current document uis unloaded. This is the case
each time you request a new page from the server...

Patrice.
 
B

bruce barker

that is correct. the event fire whenever a page is unloaded, which will
happen with any navigation. there is no browser event tied to actual browser
close. you can host your site in a frameset that detects the close, which
would be closer to want you want.

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,778
Messages
2,569,605
Members
45,238
Latest member
Top CryptoPodcasts

Latest Threads

Top