diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/xmlhttprequest/using_xmlhttprequest_in_ie6/index.html | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/api/xmlhttprequest/using_xmlhttprequest_in_ie6/index.html')
-rw-r--r-- | files/zh-cn/web/api/xmlhttprequest/using_xmlhttprequest_in_ie6/index.html | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/xmlhttprequest/using_xmlhttprequest_in_ie6/index.html b/files/zh-cn/web/api/xmlhttprequest/using_xmlhttprequest_in_ie6/index.html new file mode 100644 index 0000000000..2c1231a04a --- /dev/null +++ b/files/zh-cn/web/api/xmlhttprequest/using_xmlhttprequest_in_ie6/index.html @@ -0,0 +1,28 @@ +--- +title: 在 IE6 中使用 XMLHttpRequest +slug: Web/API/XMLHttpRequest/Using_XMLHttpRequest_in_IE6 +translation_of: Web/API/XMLHttpRequest/Using_XMLHttpRequest_in_IE6 +--- +<p><a href="/zh-CN/DOM/XMLHttpRequest" title="zh-CN/DOM/XMLHttpRequest">XMLHttpRequest</a> 在 Internet Explorer 5.0 上作为 ActiveX 控件第一次被 Microsoft 引入。然而,在 IE7 和其它浏览器上,XMLHttpRequest 作为本地 JavaScript 对象而存在。</p> + +<p>在现代的浏览器上,你可以使用下面的代码创建一个新的 XMLHttpRequest 对象:</p> + +<pre class="brush: js">var request = new XMLHttpRequest() +</pre> + +<p>如果你需要支持 Internet Explorer 6 和更老的浏览器,你需要像下方所示扩展你的代码:</p> + +<pre class="brush: js">if (window.XMLHttpRequest) { + //Firefox、 Opera、 IE7 和其它浏览器使用本地 JavaScript 对象 + var request = new XMLHttpRequest(); +} else { + //IE 5 和 IE 6 使用 ActiveX 控件 + var request = new ActiveXObject("Microsoft.XMLHTTP"); +} +</pre> + +<h3 id="更多">更多</h3> + +<ul> + <li><a href="/zh-CN/DOM/XMLHttpRequest/Using_XMLHttpRequest" title="使用 XMLHttpRequest">使用 XMLHttpRequest</a></li> +</ul> |