<html>
<head>
<script>
function closeWindow(){
if(window.confirm("是否要退出本系统","退出")){
window.opener=null;
window.close();
}
}
</script>
</head>
<body>
<p>系统测试</p>
<p>
<button onclick="javascript:closeWindow();">关闭</button>
</p>
</body>
</html>
如果你的页面是包含在框架中,则在function closeWindow()函数中写法如下:
if(window.confirm("是否要退出本系统","退出")){
parent.window.opener=null;
parent.window.close();
}
本文介绍了一种使用JavaScript在网页上实现关闭窗口前显示确认对话框的方法,并针对不同页面结构(如是否嵌套在框架内)提供了相应的代码示例。
2004

被折叠的 条评论
为什么被折叠?



