Possible Duplicates:
How can I ask a web user for confirmation if he really wants to leave the page?
Client/JS Framework for “Unsaved Data” Protection?
Like stackoverflow does on the ask page, when I click the close button or any other link on the site a dialog pops up asking if you're sure you want to navigate away from the page. How to do that in javascript or jQuery and can you customize the text in the box?