Закрытие окна JS

window.onbeforeunload = function(){
  alert("You are now leaving, are you sure?")
}
DatMADCoder