Click here to Skip to main content
13,051,502 members (63,051 online)
Rate this:
Please Sign up or sign in to vote.
See more:
How can I handle internet explorer buttons in e.g back, forward
and I want to that when any one click the close button then it display message (ok, cancel)
Posted 16-Feb-13 20:01pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Use onbeforeunload event - It is called before the unload event when you click the close button.

An article on similar lines: Save Changes on Close of Browser or When Exiting the Page[^]
riteshsingh_jsr 17-Feb-13 2:23am
Not worked Sandeep....
Sandeep Mewara 17-Feb-13 2:38am
Don't just copy-paste and then say 'not working'. Seriously it discourages to answer such questions.

That is the event to use. Tie it with a JS method such that when it is raised, ask if they want to close or not.
Similar discussion if you need to know more around it:
Rate this: bad
Please Sign up or sign in to vote.

Solution 2


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 17 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100