Prompting and preventing user from navigating away/closing a page

Posted by GordonB on Stack Overflow See other posts from Stack Overflow or by GordonB
Published on 2010-04-14T15:59:49Z Indexed on 2010/04/14 16:13 UTC
Read the original article Hit count: 266

Filed under:

As per how StackOverflow does it when you are adding a question or replying to a question;

I'd like to prompt the user with a;

"Are you sure you want to navigate away from this page"
"Press OK to continue or Cancel to stay on this page"

I've tried a couple of js snippets i've found on ze internet, but nothing quite cuts the mustard.

© Stack Overflow or respective owner

Related posts about JavaScript