RT,附上代码先function login_step(step)
 {
     alert(step);
    if(window.XMLHttpRequest)
    { 
        var xmlReq = new XMLHttpRequest(); 
        alert(1);
    }
    else if(window.ActiveXObject) 
    { 
        var xmlReq = new ActiveXObject('Microsoft.XMLHTTP'); 
        alert(2);
    }
    alert(2.5);
    var URL="login_step.php?step="+step+"&pid="+pid+"&s_time="+s_time+"&id_lonstep="+id_lonstep+"&falshversion="+falshversion+"&sid="+new Date().getTime();
    alert(URL);
    xmlReq.onreadystatechange = function()
    { 
        alert(xmlReq.status);
        if(xmlReq.readyState == 4)
        { 
            if(xmlReq.status==200)
            {
            }
            else
            {
                alert(URL);
                alert('动态页2面出错\n\n'+xmlReq.responseText+step);//如果状态不是200,输出错误看看            }
        } 
    } 
        
    xmlReq.open("GET", URL, true);             
    xmlReq.send(null);     
    return false; 
 }window.onunload=function()
    {
         login_step("close");
    }谷狗浏览器下刷新的时候,会直接运行到Login_step这个函数的xmlReq.onreadystatechange 的这一步,也就是说前面的alert(1)、alert(2.5)等等都不会执行,直接报动态页面出错了。打印alert(xmlReq.status)为0.在IE和FF都正常,请问是什么原因?该如何修改!
在线等解答

解决方案 »

  1.   

    function login_step(step)
     {
     var xmlReq = null;
         alert(step);
        if(window.XMLHttpRequest)
        { 
            xmlReq = new XMLHttpRequest(); 
            alert(1);
        }
        else if(window.ActiveXObject) 
        { 
            xmlReq = new ActiveXObject('Microsoft.XMLHTTP'); 
            alert(2);
        }
        alert(2.5);
        var URL="login_step.php?step="+step+"&pid="+pid+"&s_time="+s_time+"&id_lonstep="+id_lonstep+"&falshversion="+falshversion+"&sid="+new Date().getTime();
        alert(URL);
        xmlReq.onreadystatechange = function()
        { 
            alert(xmlReq.status);
            if(xmlReq.readyState == 4)
            { 
                if(xmlReq.status==200)
                {
                }
                else
                {
                    alert(URL);
                    alert('动态页2面出错\n\n'+xmlReq.responseText+step);//如果状态不是200,输出错误看看            }
            } 
        } 
            
        xmlReq.open("GET", URL, true);             
        xmlReq.send(null);     
        return false; 
     }window.onunload=function()
        {
             login_step("close");
        }
    把xmlReq在函数第一句的时候声明下~·
      

  2.   

    我在Chrome 13.0.782.107 里测试没有问题啊,刷新后依次弹出的是
    (1).close
    (2).1
    (3).2.5
    (4).URL
      

  3.   

    为什么我的不行???
    我是直接弹出了alert(xmlReq.status);
    这一步。2L的方法也不行。求解!!!