脚 本 之 家 www.jb51.net
页面导航: 首页网络编程JavaScriptjavascript技巧 → 正文内容

firefox中JS读取XML文件

发布:dxy 字体:[增加 减小] 类型:转载
firefox中JS读取XML文件
在网上搜“firefox中JS读取XML文件”的方法,找了半天,好多都是问了没人答的。看到一堆程序员在抱怨firefox:“除了累死程序员没什么好处。”,言归正传。firefox不支持ie中的ActiveXObject对象,要得到一个XML DOM有以下2种方法:
1、document.implementation.createDocument("", "", null);
2、window.XMLHttpRequest
示例:1、var dom=document.implementation.createDocument("", "", null);
dom.async=false;
dom.load("test.xml");//dom就是xml对象了。
2、var oXmlHttp = new XMLHttpRequest() ;
oXmlHttp.open( "GET", "test.xml", false ) ;
oXmlHttp.send(null) ;
//oXmlHttp.responseXML就是xml对象了。

文章评论

共有 位脚本之家网友发表了评论我来说两句

最 近 更 新
热 点 排 行