【问题标题】:How does XMLHttpRequest relate to the JS Window objectXMLHttpRequest 与 JS Window 对象有什么关系
【发布时间】:2017-08-01 05:40:44
【问题描述】:

在阅读XMLHttpRequest 时发现它是高级JS 全局window 对象的成员。例如:

if (window.XMLHttpRequest) { // Mozilla, Safari, IE7+ ...
    httpRequest = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE 6 and older
    httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}

但我无法在其他任何地方确认此信息?我在这里查看https://developer.mozilla.org/en-US/docs/Web/API/Window 以查看是否可以找到XMLHttpRequest 对象,但没有提及它。我错过了什么吗?只是想确保我了解XMLHttpRequest 的正确来源以及它与全局window 对象的关系。

【问题讨论】:

    标签: javascript xmlhttprequest specifications window-object webidl


    【解决方案1】:

    the WebIDL definition for the XMLHttpRequest interface:

    [Constructor, Exposed=(Window,DedicatedWorker,SharedWorker)]
    interface XMLHttpRequest : XMLHttpRequestEventTarget {
    …
    }
    

    因此,这需要 XMLHttpRequestWindow 以及 DedicatedWorkerSharedWorker 公开(在实际实现这些的 UA 中)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-05-08
      • 2015-09-03
      • 1970-01-01
      • 2015-05-31
      • 2016-06-11
      • 2019-09-14
      • 2011-08-19
      相关资源
      最近更新 更多