Believe it,do it!

Ideal is the beacon. Without ideal, there is no secure direction; without direction ,there is no life.
理想是指路明灯。没有理想,就没有坚定的方向;没有方向,就没有生活。
CTRL+T eclipse
posts - 35, comments - 3, trackbacks - 0, articles - 0
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

IE窗口关闭时如何提交JS事件

Posted on 2011-01-25 14:21 三羽 阅读(1693) 评论(0)  编辑  收藏 所属分类: JS 脚本
  在网页中加入下列代码就知道效果了    
  1、=====================================================
<script type="text/javascript">
window.onbeforeunload = function()
       {   
              var n = window.event.screenX - window.screenLeft;   
              var b = n > document.documentElement.scrollWidth-20;   
              if(b && window.event.clientY < 0 || window.event.altKey)   
              {   
                     openwin();
                     alert('查看弹出');  
                     window.event.returnValue = ""; //这里可以放置你想做的操作代码   
              }   
       }
      
function openwin(){
alert();
//写下事件
}   
</script> 
2、==========================================================
<script type="text/javascript">  
<!--    
    window.onbeforeunload = onbeforeunload_handler;  
    window.onunload = onunload_handler;  
    function onbeforeunload_handler(){  
        var warning="确认退出?";          
        return warning;  
    }  
      
    function onunload_handler(){  
        var warning="谢谢光临";  
        alert(warning);  
    }  
// -->  
</script>

只有注册用户登录后才能发表评论。


网站导航: