离开当前页面前使用js判断条件提示是否要离开页面

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

离开当前页面前使用js判断条件提示是否要离开页面

  2020-05-13 我要评论
复制代码 代码如下:

<!doctype html>
<html lang="cn">
<head>
<meta charset="UTF-8">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>js离开当前页面前判断条件提示是否要离开页面</title>
<script type="text/javascript">
window.onbeforeunload = function()
{
var unloads = document.getElementById("unloads").value;
if(unloads == null || unloads == ""){
return "您确定要退出页面吗?";
}
}
</script>
</head>
<body>
<input type="text" id="unloads" name="unloads" value="" />
</body>
</html>

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们