From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../using_xmlhttprequest_in_ie6/index.html | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 files/zh-cn/web/api/xmlhttprequest/using_xmlhttprequest_in_ie6/index.html (limited to 'files/zh-cn/web/api/xmlhttprequest/using_xmlhttprequest_in_ie6/index.html') 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 +--- +

XMLHttpRequest 在 Internet Explorer 5.0 上作为 ActiveX 控件第一次被 Microsoft 引入。然而,在 IE7 和其它浏览器上,XMLHttpRequest 作为本地 JavaScript 对象而存在。

+ +

在现代的浏览器上,你可以使用下面的代码创建一个新的 XMLHttpRequest 对象:

+ +
var request = new XMLHttpRequest()
+
+ +

如果你需要支持 Internet Explorer 6 和更老的浏览器,你需要像下方所示扩展你的代码:

+ +
if (window.XMLHttpRequest) {
+    //Firefox、 Opera、 IE7 和其它浏览器使用本地 JavaScript 对象
+    var request = new XMLHttpRequest();
+} else {
+    //IE 5 和 IE 6 使用 ActiveX 控件
+    var request = new ActiveXObject("Microsoft.XMLHTTP");
+}
+
+ +

更多

+ + -- cgit v1.2.3-54-g00ecf