Check if user hits back button in browser?

You can't know in advance on which page your user will go when he leaves your page. You can't even get the URLs in its current history I see no solution to your problem and I doubt there's one, sorry.

You can't know in advance on which page your user will go when he leaves your page. You can't even get the URLs in its current history. I see no solution to your problem and I doubt there's one, sorry.

1 You can't always know in advance, but you can sometimes have a pretty good idea. For example, a mousedown on a link is a pretty good indication that someone is going to allow mouseup on the link and follow it. – thetaiko Dec 20 '10 at 22:06 1 Well, yes, that's tricky, but you can know when an user will leave your website attaching a function to the onclick event of an external link for example.

But when he doesn't click on a link, you can't know whether he hits the back button, closes his browser, or enters a new URL in his browser directly. – Pikrass Dec 20 '10 at 22:14 See above edits for my solution to determining when the user hits the back button in Internet Explorer. I'm looking for another way to indicate a back button hit in browsers other than IE.

– Rick Dec 22 '10 at 14:23.

Short answer: No. Long answer: Noooooooooooooooooooooooooooo. Please don't try to keep users on your website unless you have a very good reason to.

Saving form fields would be an example of a good use. Checking if they're moving on to another website would be a bad use. People don't travel from page-to-page as much as they did in the early days of the web.

Instead they use google and social networks to find interesting pages, and consume separate distinct pieces of information.

If you don't want anything to happen when the user clicks the back button, then you don't necessarily need to determine if the back button has been hit. Your goal is to determine who will "most likely be staying on your site," and create an extra step for everyone who wants to leave. You're trying to interrupt and override the user's expectations of how his browser will behave.

If you really want to do this, have event listeners for all unload events that aren't triggered by the back button: every link on your page, closing the window, etc. It won't be easy, and you won't be able to catch all events. But you're going to be pissing people off unless you have a good reason for doing this, so if it's really important then put the extra effort in.Tl;dr: Add event listeners to everything that isn't the back button and bring up the dialog in the callback function. It will piss people off, though.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions