我想做的是当用户点击浏览器右上角关闭页面的时候,弹出提示框。让用户选择,1、是:关闭页面;2、跳转到首页;3、不做任何操作,以下代码在点关闭的时候会弹出提示框。。但选择了是、否、取消之后都会关闭页面。。我需要做的是用户选择不同的按钮后会按照我的要求做。。比如。点关闭之后弹出提示框,我选择了否,就应该跳转到首页,选择了取消就不做操作,选择了是就关闭页面。。还有可不可以在用户刷新的时候不要弹出提示框,只有在关闭的时候才弹出提示框的<SCRIPT LANGUAGE="VBScript">
<!--function MyVbconfirm2()
    return = msgbox ("您正准备离开订单页面,请选择:"&vbcrlf &""&vbcrlf &"是:我不想继续订单了确定要离开此页面;"&vbcrlf &""&vbcrlf &"否:我想到主页内挑选其他产品并购买;"&vbcrlf &""&vbcrlf &"取消:不进行任何操作;",3+vbInformation,"友情提示")
    if return=6 then
    window.opener=null
        window.close()
    elseif return=7 then
         window.location="/"
    else
    
    end if
end function//-->
</SCRIPT><script language="javascript">
window.onbeforeunload = function(){
MyVbconfirm2()
}</script>

解决方案 »

  1.   

    <script language="javascript">
    window.onbeforeunload = function(){
    MyVbconfirm2();
    return false;
    }</script>
      

  2.   

    SCRIPT LANGUAGE="VBScript">
    <!--function MyVbconfirm2()
        return = msgbox ("您正准备离开订单页面,请选择:"&vbcrlf &""&vbcrlf &"是:我不想继续订单了确定要离开此页面;"&vbcrlf &""&vbcrlf &"否:我想到主页内挑选其他产品并购买;"&vbcrlf &""&vbcrlf &"取消:不进行任何操作;",3+vbInformation,"友情提示")
        if return=6 then
        window.opener=null
            window.close()
    MyVbconfirm2=true
        elseif return=7 then
             window.location="/"
    MyVbconfirm2=false
        else
    MyVbconfirm2=false
        end if
    end function//-->
    </SCRIPT>js
    <script language="javascript">
    window.onbeforeunload = function(){
    return MyVbconfirm2()
    }</script>
      

  3.   


    <!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" />
    <title>绑定函数</title>
    <script>
    bIsRefresh=false;

    function test(){
    bIsRefresh=true;
    location.reload();
    }


    window.onbeforeunload = function(e) {
    e=e||window.event;
    if (window.bIsRefresh)return;//刷新跳出函数 
    e.returnValue="关闭??????"
    alert("关闭");
    }
    </script></head><body>
        <p onclick='test()'>刷新测试</p>
    </body>
    </html>