我想写个html语句 点击“离开”弹出alert问是否确定 点击alert的确定窗口关闭 请问怎么写?

来源:百度知道 编辑:UC知道 时间:2024/05/03 20:23:50
我想写个html语句 点击“离开”弹出alert问是否确定 点击alert的确定窗口关闭 请问怎么写?

onclick="if(confirm('are u sure?')) window.close();"

离开页面弹出窗口

--------------------------------------------------------------------------------

脚本说明:
第一步:把如下代码加入<head>区域中
<script LANGUAGE="JavaScript">

<!-- Begin
function leave() {
window.open('tan1.htm','','toolbar=no,menubar=no,location=no,height=225,width=235');
}
// End -->
</script>

第二步:把<body>区域中内容改为:
<body bgcolor="#fef4d9" onUnload="leave()">