ff 不支持new ActiveXObject

解决方案 »

  1.   

    http://developer.mozilla.org/en/docs/AJAX:Getting_Started有中文版的:http://developer.mozilla.org/cn/docs/AJAX:Getting_Started
      

  2.   

    <script type="text/javascript">
    var xmlhttp;
    var turl="http://marvel.hit.edu.cn:8080/weblogs/2004_8_22.xml";
    loadXMLDoc(turl);
    function loadXMLDoc(url)
    {
    try{
    // code for Mozilla, etc.
    if (window.XMLHttpRequest)
      {
      xmlhttp=new XMLHttpRequest();
      //xmlhttp.onreadystatechange=xmlhttpChange;
      alert(xmlhttp.send );
     // xmlhttp.open("GET",url,true);
      xmlhttp.send(null);
      }
    // code for IE
    else if (window.ActiveXObject)
      {
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        if (xmlhttp)
        {
        xmlhttp.onreadystatechange=xmlhttpChange;
        xmlhttp.open("GET",url,true);
        xmlhttp.send();
        }
      }
      }
      catch(e)
      {alert(e.Message);}
    }function xmlhttpChange()
    {
    // if xmlhttp shows "loaded"
    /*if (xmlhttp.readyState==4)
      {
      // if "OK"
      if (xmlhttp.status==200)
        {
        // ...some code here...
        alert("OK"+xmlhttp.responseText);
        }
      else
        {
        alert("Problem retrieving XML data");
        }
      }*/
    }
    </script>
      

  3.   

    //url为需要打开的xml文件地址
    //onready为在加载完成后需要执行的命今
    function xmlhttp_async(url,onready){
    if ( url==null || url=="" ) return false;
    if ( window.ActiveXObject && !window.XMLHttpRequest ) 
    x = new ActiveXObject( "Microsoft.XMLHTTP" ); // IE
    else
    x = new XMLHttpRequest(); // Mozilla, Opera
    x.open("GET",url,true);
    x.send();
    if(onready!=""){
    x.onreadystatechange =function() {
     //304 for Opera 
    if ( x.readyState==4 && (x.status==200||x.status==304) ){
    eval(onready);
    }
    }
    } }
      

  4.   

    但是我试过,url为file:///是没有问题,但是http://的时候就有问题。可能使权限问题,诡异……