javascript跨浏览器创建XML对象

var   xmlDoc   =   null ;

function   parseXML ( xmlUrl )

{

  try   {

    //IE

    xmlDoc   =   new   ActiveXObject ( "Microsoft.XMLDOM" );

    xmlDoc . async   =   false ;

    xmlDoc . load ( xmlUrl );

  } catch ( e )

  {

    try {

    // Firefox Mozilla Opera etc .

    xmlDoc   =   document . implementation . createDocument ( "" , "" , null );

    xmlDoc . async   =   false ;

    xmlDoc . load ( xmlUrl );

    } catch ( e )

    {

      try {

        // google , Safari

        var   xmlhttp   =   new   window . XMLHttpRequest ();

        xmlhttp . open ( "GET" , xmlUrl , false );

        xmlhttp . send ( null );

        xmlDoc   =   xmlhttp . responseXML . documentElement ;

      } catch ( e ){ alert ( e . message + "  EROR" ); return ;}

    }

  }

}

阅读更多
换一批

没有更多推荐了,返回首页