首页 > 语言 > JavaScript > 正文

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

2024-05-06 16:04:59
字体:
来源:转载
供稿:网友
这篇文章主要介绍了离开当前页面前如何使用js判断条件提示是否要离开页面,需要的朋友可以参考下

复制代码 代码如下:


<!doctype html>
<html lang="cn">
<head>
<meta charset="UTF-8">
<meta content="">
<meta 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" value="" />
</body>
</html>

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选