日期:2014-05-16  浏览次数:20403 次

关闭ie窗口如何获得事件
就是说当我点击ie右上角的叉关闭时。我用javascript做个操作,那么该如何获得关闭事件

比如说点右上角叉关闭时   alert( "don 't   close   me ");

------解决方案--------------------
body unload 事件.
------解决方案--------------------
function onbeforeunload ()
{
alert( "don 't close me ");
}
------解决方案--------------------
<script language= "javascript ">
window.onbeforeunload = function() //author: meizz
{
var n = window.event.screenX - window.screenLeft;
var b = n > document.documentElement.scrollWidth-20;
if(b && window.event.clientY < 0 || window.event.altKey)
{
window.event.returnValue = "don 't close me ";
}
}
</script>