日期:2014-05-18  浏览次数:20757 次

responseText 能否使用getElementsByTagName方法
<!DOCTYPE   HTML   PUBLIC   "-//W3C//DTD   HTML   4.01   Transitional//EN ">
<html>
    <head>
        <title> MyHtml.html </title>
<script   language= "javascript ">


function   call(){
var   xml=new   ActiveXObject( "Microsoft.XMLHTTP ");
xml.open( "GET ", "http://www.daum.net/ ",true);
xml.send();
var   ret=xml.responseText;
var   titles=   xdoc.getElementsByTagName( "title ");  
alert(titles[0].innerText);//显示网页的标题  
}

</script>
        <meta   http-equiv= "keywords "   content= "keyword1,keyword2,keyword3 ">
        <meta   http-equiv= "description "   content= "this   is   my   page ">
        <meta   http-equiv= "content-type "   content= "text/html;   charset=UTF-8 ">
       
     

    </head>
   
    <body>
    <input   type= "button "   onClick= "call() "   value= "Get! ">
    </body>
</html>


如题,希望大家帮忙,或者帮助我修改一下我的代码,打印出来title就可以了,谢谢

------解决方案--------------------
responseText不能使用getElementsByTagName方法,responseText返回的是字符串
responseXML可以使用getElementsByTagName方法