An interesting question has been posed on the 404 Tech Support forums asking about those pop-up dialogs you might receive every once in a while that start with “Are you sure you want to navigate away from this page?”. The question also asks, “Are there any dangers related to this? Will it install malware? Is there a way to block it automatically?” These are very good questions that we should all be pondering for security reasons. Let me share with you what my experience and research can tell about these somewhat intruisive, but potentially very helpful dialog boxes.
I encounter these messages daily for many legitimate reasons. Here are a few of those cases:
- WordPress – 404 Tech Support is powered by WordPress. If I am writing up a new post and forget to save but try to go somewhere else in that tab, I’ll see the message with “The changes you made will be lost if you navigate away from this page.” After you save the post, you can navigate away without seeing this message.
- Gmail – Every once in a while I can catch Gmail showing this message if an e-mail hasn’t been sent or auto-saved or it’s doing something that’s taking a while. Usually a little status message will be shown at the top of Gmail, but you’ll see this message if you try to navigate away with “Your message has not been sent.”
- Google Docs – Google Docs auto-saves very frequently so it’s hard to catch it when there have been unsaved changes to the document. If you do, you’ll see this message with “You have unsaved changes in this document. Click Cancel now, then ‘Save’ to save them. Click OK now to discard them.”.
- Ad sites – I used to be a member of an e-mail ad service. They’d e-mail you a link, you click on it, and it takes you to an advertising partner’s website. For each e-mail you would earn anywhere between 1 to 5 cents. In the last few months that I was apart of it, a lot of these sites, started implementing this message to make it difficult for you to leave the page and stay on the site longer. This was one of the reasons I cashed out and unsubscribed from this service.
The exact message states in Firefox:
Are you sure you want to navigate away from this page?
Any string value… (This line can change per site/page.)
Press OK to continue, or Cancel to stay on the current page.
I took the example code used in that article and created a simple page with it so you can see it in action and view the source to see how simple it is. You can find it here: http://www.404techsupport.com/blog/script.html