/    Sign up×
Community /Pin to ProfileBookmark

Confirm closing browser window.

I have an e-learning program where some users are closing out before they are finished. I would like to make it so if they choose the X in the browser or choose File Close from the menu bar, they will get a confirm box telling them they are not finished and do they still want to close the program. I would like them to be able to navigate away from the page by clicking on a link or using the back and forward button in the browser. Can this be done?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@pyroJun 19.2003 — No. There is no way to check [I]how[/I] the browser is leaving the page, you can only check [I]if[/I] it is...
Copy linkTweet thisAlerts:
@AdamGundryJun 19.2003 — You could put the confirm box in onUnload, and override it if one of the links has been clicked. They would still get the message if they pressed forward or back, however. Of course, there's not much you can do if they close the window anyway.

Adam
Copy linkTweet thisAlerts:
@pyroJun 19.2003 — Yes, and now that you mentioned that Adam, I remember a script Charles wrote to loop through the links and clear the function if one was clicked... That, of course, will not work for the back or forward button, but it's a start. Perhaps a search of these forums would find it for you...
Copy linkTweet thisAlerts:
@parkeauthorJun 19.2003 — Thanks. I do have a script to do that with the links. I was just hoping there was something else that would work for the back and forward buttons.
×

Success!

Help @parke spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...