挑战效果图:  在用户点击浏览器窗口右上角叉叉,页面做出提示弹窗提示:(请问你是需要进入百度搜索一下吗?www.baidu.com), 确定按钮:页面跳转到百度页面, 取消按钮:页面关闭。    需要的效果就是这样“不管你是使用javascript  还是jquery做,主要需要效果!!!”条件: 兼容ie、火狐、google浏览器;
        各位朋友来挑战下自己吧!  也算帮帮我了,没撒回报大家都 ,全部身家积分都拿出来了,谢谢各位朋友了

解决方案 »

  1.   

    利用DOM模型的 OnBeforeUnload 事件
     
    <body  onbeforeunload="return RunOnBeforeUnload()">
      

  2.   

    实现这种效果跟用不用jquery没多大关系 jquery主要是封装了dom操作、ajax、简单动画效果等
    关闭浏览器或者标签页属于浏览器操作 跟页面没多大关系 可以试试 onbeforeunload、onunload,但浏览器兼容有问题,还有很多浏览器会阻止这种js执行(可能为了阻止关闭网页时的弹窗广告)
    最好的办法是不要做这种应用 想其他办法 注意b/s结构的特点
      

  3.   

    window.onbeforeunload = function()
    {
         if(confirm("确定要进入百度吗?"))
         {
              window.open("http://www.baidu.com");
         }
    }
    只能在ie下满足你的要求
      

  4.   

    <HTML>
    <HEAD>
    <SCRIPT>
    function closeWin(event)
    {
        e = window.event || event;
        if(e.preventDefault)
        {   
            e.preventDefault();
        }
        else
        {
            e.returnValue="";
        }
    }
    </SCRIPT>
    </HEAD>
    <BODY onbeforeunload="closeWin(event)"></BODY>
    </HTML>
    我真是已经尽力了 再监听确定 取消按钮 真无解了~~~~~
      

  5.   


       先谢谢你了,有朋友说根据你的窃取在使用jquery制作虚拟对话框,  很伤心,自己不会
      

  6.   

    <script type="text/javascript">
    document.all?window.attachEvent('onbeforeunload',
    function()
    {
    if(confirm('百度一下')){window.location.href="http://www.baidu.com";}
    else
    {
    alert();
    }
    }
    ):
    window.addEventListener('beforeload',
    function(){
    if(confirm('百度一下')){window.location.href="www.baidu.com";}else{alert();};},
    true);
    </script>   这个只能兼容ie, 别的浏览器又不行。
      

  7.   


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title> New Document </title>
    <meta name="Generator" content="EditPlus">
    <meta name="Author" content="">
    <meta name="Keywords" content="">
    <meta name="Description" content="">
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
    $(window).unload(function(){
    if(confirm("确定要进入百度吗?")){
    window.open("http://www.baidu.com");
    }
    });
    });
    </script>
    </head>
    <body></body>
    </html>
    这样?
      

  8.   

    其实不难。这样就行
    <html>
    <head>
        <script>            window.onbeforeunload = function()
                {
                    if(confirm("baidu?")){
                        
                    window.location.href="http://www.baidu.com";
                    return false;
                    }
                }
    </script>
    </head>
    <body >

    </body>
    </html>
      

  9.   

    LS的仁兄,我怎么用google浏览器测试没效果呢,请问是否我浏览哪里没有设置到,还是?
      

  10.   

     Javascript和CSS浏览器兼容总结 window.onbeforeunload = function()
    {
         if(confirm("确定要进入百度吗?"))
         {
              window.open("www.baidu.com");
         }
    }
      

  11.   


    google浏览器不知道 我这就有IE和火狐
      

  12.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type='text/javascript'>
    window.onunload=function(){
    if(window.confirm('去网易?')){
    var f=document.getElementById('outf');
    f.submit();
    }else{

    }
    }
    </script>
    </head>
       <body>
       <form id='outf' style='display:none' action='http://www.163.com' target='_blank' >
       </form>
      </body>
    </html>懒得测兼容性了 概念就是这样