针对 frameset 的关闭我写了一个例子, 你自己看吧:
框架网页的关闭事件捕捉
<html>
<head>
<title>框架网页的关闭事件捕捉</title>
<script language="javascript"> //当然这里可以不用条件编译这样的东西
/*@cc_on @*/
/*@if (@_win32 && @_jscript_version>=5)
function window.onbeforeunload() //author: meizz
{
var b = event.clientX>window.frameTop.document.body.clientWidth-20;
//注意 window.frameTop 里的 frameTop 与框架里的横向框架页 name 对应
if(b && window.event.clientY < 0 || window.event.altKey)
{
window.event.returnValue = ""; //这里可以放置你想做的操作代码
}
}
@end @*/
</script>
</head>
<frameset rows="100, *">
<frame name=frameTop>
<frameset cols="160, *">
<frame name=frameLeft>
<frame name=frameRight>
</frameset>
<noframes>
<body>
<h2 align="center">对不起!你的浏览器不支持框架网页</h2>
</body>
</noframes>
</frameset>
</html>
框架网页的关闭事件捕捉
<html>
<head>
<title>框架网页的关闭事件捕捉</title>
<script language="javascript"> //当然这里可以不用条件编译这样的东西
/*@cc_on @*/
/*@if (@_win32 && @_jscript_version>=5)
function window.onbeforeunload() //author: meizz
{
var b = event.clientX>window.frameTop.document.body.clientWidth-20;
//注意 window.frameTop 里的 frameTop 与框架里的横向框架页 name 对应
if(b && window.event.clientY < 0 || window.event.altKey)
{
window.event.returnValue = ""; //这里可以放置你想做的操作代码
}
}
@end @*/
</script>
</head>
<frameset rows="100, *">
<frame name=frameTop>
<frameset cols="160, *">
<frame name=frameLeft>
<frame name=frameRight>
</frameset>
<noframes>
<body>
<h2 align="center">对不起!你的浏览器不支持框架网页</h2>
</body>
</noframes>
</frameset>
</html>
感谢你的例子,但是event.clientX如果是对应frameRight那么b是false!也就是我最头疼的!