safaricn
Safari首页 | Safari新闻 | Safari试用 | Safari下载 | Safari技巧 | Safari问答 | Safari中文 | 浏览器大全
欢迎访问 Safari中文网 [Apple Safari浏览器] 三大浏览器之一 世界上最快的网页浏览器 苹果Safari  
Safari>Safari开发> Safari浏览器DHTML和Xml兼容性问题
Safari浏览器DHTML和Xml兼容性问题
[ 来源:www.safaricn.com ] [ 作者:Safari中文网 Safari之家 ][ 时间:2007-11-02 ]

 

  随着部署xml数据和网络服务变得更为普遍,偶尔你会感到方便连接的html介绍直接到xml数据为临时升级换料页面。多亏一个鲜为人知的秘密xmlhttprequest对象,越来越多的网上用户,可以调用,并提交xml数据直接,所有在后台运行。转换检索xml数据到renderable html的内容,依赖于客户端文档对象模型(DOM) ,以读xml文档节点树和作曲html元素表示,用户看到的。
  微软首次实行xmlhttprequest对象在internet explorer五日窗口作为一个activex对象。工程师对mozilla项目实施的一个兼容的版本为mozilla浏览器1.0 (和Netscape7 ) 。苹果公司已经做了同一个起跑线上,与Safari1.2 版时,Safari中文网提示目前已经是Safari3了,相信苹果的技术。
创建对象
var req = new XMLHttpRequest();

var req = new ActiveXObject("Microsoft.XMLHTTP");

通过查看XMLHTTP相关的语法。

abort() Stops the current request
getAllResponseHeaders() Returns complete set of headers (labels and values) as a string
getResponseHeader("headerLabel") Returns the string value of a single header label
open("method", "URL"[, asyncFlag[, "userName"[, "password"]]]) Assigns destination URL, method, and other optional attributes of a pending request
send(content) Transmits the request, optionally with postable string or DOM object data
setRequestHeader("label", "value") Assigns a label/value pair to the header to be sent with a request
这里列出Safari支持的XML示例代码
var req;

function loadXMLDoc(url) {
	req = false;
    if(window.XMLHttpRequest && !(window.ActiveXObject)) {
    	try {
			req = new XMLHttpRequest();
        } catch(e) {
			req = false;
        }
     } else if(window.ActiveXObject) {
       	try {
        	req = new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		req = false;
        	}
		}
    }
	if(req) {
		req.onreadystatechange = processReqChange;
		req.open("GET", url, true);
		req.send("");
	}
}
有关XMLHTTP参数设置查看
onreadystatechangeEvent handler for an event that fires at every state change
readyStateObject status integer:
0 = uninitialized
1 = loading
2 = loaded
3 = interactive
4 = complete
responseTextString version of data returned from server process
responseXMLDOM-compatible document object of data returned from server process
statusNumeric code returned by server, such as 404 for "Not Found" or 200 for "OK"
statusTextString message accompanying the status code

版权所有 www.safaricn.com 2006-2007 Safari中文网