自知其无知
不懂,慢慢懂。
posts - 2,comments - 2,trackbacks - 0
getXMLDocument() 函数


<script type="text/javascript">
  fucntion getXMLDocument()
{
    
var xDoc = null;
    
if(document.implementation && document.implementation.createDocument){
    xDoc 
= document.implementaion.createDocument('','',null) ; // Mozilla / Safari
  }
else if(typeof ActiveXObject != 'undefined'){
  
var msXmlAx = null;
  
try{
    msXmlAx 
= new ActiveXObject("Msxml2.DOMDocument"); // 较新版本的 IE 浏览器
  }
catch(e){
    msXmlAx 
= new ActiveXObject("Msxml.DOMDocument"); // 较老版本的 IE 浏览器
  }
 
  xDoc 
= msXmlAx;
}

  
if(xDoc == null || typeof xDoc.load == 'undefined'){
   xDoc 
= null;
 }

  
return xDoc;
  }

</script>


在大多数浏览器中,这个函数都能返回一个具有相同 API 的 XmlDocument 对象,尽管在不同的浏览器中创建文档的方式有很大的不同。

这段代码检查文档对象是否支持创建一个原生的 XmlDocument 对象所需的 implementation 属性(在最近的 Mozilla 和 Safari 浏览器中都可以找到这个属性)。如果没有找到,它将测试浏览器是否支持 ActiveX 对象(只有微软的浏览器才能够支持)。
posted on 2008-12-08 22:12 CopyHoo 阅读(343) 评论(0)  编辑  收藏 所属分类: Ajax

只有注册用户登录后才能发表评论。


网站导航: