function GetXmlHttpObject(){
var xmlHttp=null;
try{
xmlHttp=new XMLHttpRequest();
}catch(e){
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
 }catch (e){
 alert("您的浏览器不支持AJAX!");
 return false;
 }
}
}
return xmlHttp;
}
请高手指点一下!

解决方案 »

  1.   

    自己顶一下,在ie或世界之窗3中都能正常执行,
    而在firefox中不行
      

  2.   

    function InitAjax(){
     var ajax=false; 
     try { 
      ajax = new ActiveXObject("Msxml2.XMLHTTP"); 
     } catch (e) { 
      try { 
       ajax = new ActiveXObject("Microsoft.XMLHTTP"); 
      } catch (E) { 
       ajax = false;
      }
     }
     if (!ajax && typeof XMLHttpRequest!='undefined') { 
      ajax = new XMLHttpRequest(); 
     } 
     return ajax;
    }
      

  3.   

    试过不行,还发现firefox进不了js里面
    试过alert("test");
    ie等有打印,而firefox却没有反应 
      

  4.   

    你确认是这段代码的问题吗?装了firebug没有?看看firefox下报什么错
      

  5.   

     ajax 执行要看你的AJAX里面是怎么写的。你这个就不能在FOXfile下执行!
      

  6.   

     ajax 执行要看你的AJAX里面是怎么写的。你这个就不能在FOXfile下执行!
      

  7.   

    XmlHttpRequest对象在不同浏览器中不同的创建方法,以下是跨浏览器的通用方法:// Provide the XMLHttpRequest class for IE 5.x-6.x:
    // Other browsers (including IE 7.x-8.x) ignore this
    //   when XMLHttpRequest is predefined
    if (typeof(XMLHttpRequest) == "undefined") 
    {
    XMLHttpRequest = function() {
    try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); }
    catch(e) {}
    try { return new ActiveXObject("Msxml2.XMLHTTP.4.0"); }
    catch(e) {}
    try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); }
    catch(e) {}
    try { return new ActiveXObject("Msxml2.XMLHTTP"); }
    catch(e) {}
    try { return new ActiveXObject("Microsoft.XMLHTTP"); }
    catch(e) {}
    throw new Error("This browser does not support XMLHttpRequest.");
    };
    }
     
    xmlhttp_request = new XMLHttpRequest();
      

  8.   

    XMLHttpRequest对象的创建方式因浏览器不同而有所不同。对于Safari和Mozilla来说,其创建方式如下所示:              var req = new XMLHttpRequest();    
      

  9.   


    var request=null;
    function createRequest(){
    try{
    request=new XMLHttpRequest();
    }catch(trymicrosoft){
    try{
    request=new ActiveXObject("Msxml2.XMLHTTP");
    }catch(othermicrosoft){
    try{
    request=new ActiveXObject("Microsoft.XMLHTTP");
    }catch(failed){
    request=null;
    }
    }
    }

    if(request==null){
    alert("Error creating request object!");
    }
    }