Before leaving the current page use js to determine whether the conditional prompt should leave the page

  • 2020-03-30 02:49:31
  • OfStack

 
<!doctype html> 
<html lang="cn"> 
<head> 
<meta charset="UTF-8"> 
<meta name="Keywords" content=""> 
<meta name="Description" content=""> 
<title>js Leave the current page before the condition prompt to determine whether to leave the page </title> 
<script type="text/javascript"> 
window.onbeforeunload = function() 
{ 
var unloads = document.getElementById("unloads").value; 
if(unloads == null || unloads == ""){ 
return " Are you sure you want to exit the page? "; 
} 
} 
</script> 
</head> 
<body> 
<input type="text" id="unloads" name="unloads" value="" /> 
</body> 
</html> 

Related articles: