Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Confirm message before leaving site cross browser (JS)

Tags:

javascript

Want to make a confirm box appear before someone leave my site. They have information that will go lost if they leave and you don´t want that right. Pleas be specific with were I should put the code and so since I´m not the best of coders...

like image 243
Xweque Avatar asked May 12 '12 18:05

Xweque


1 Answers

window.onbeforeunload = function(){
    return "Are you sure you wanna leave my site?";
}
like image 174
Danilo Valente Avatar answered Sep 21 '22 14:09

Danilo Valente