XMLHttpRequest()与ActiveXObject(& quot; Microsoft.XMLHTTP& quot;)-重点是什么? [英] XMLHttpRequest() vs ActiveXObject("Microsoft.XMLHTTP") - what's the point?

查看:37
本文介绍了XMLHttpRequest()与ActiveXObject(& quot; Microsoft.XMLHTTP& quot;)-重点是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Microsoft最终在Internet Explorer 7中添加了本机XMLHttpRequest对象,但是我发现可以在"Internet选项"对话框中将其禁用.那么使用XMLHttpRequest()和ActiveXObject("Microsoft.XMLHTTP")有什么好处?

Microsoft finally added the native XMLHttpRequest object in Internet Explorer 7, but I found out that it can be disabled in the Internet Options dialog. So what benefit is there using XMLHttpRequest() vs ActiveXObject("Microsoft.XMLHTTP")?

如果可以禁用它,则意味着我们必须永远保持浏览器兼容性检查,不是吗?XMLHttpRequest()初始化会比ActiveXObject("Microsoft.XMLHTTP")更快吗?微软为什么要添加它并使它成为可选的?

If it can be disabled, that means we have to keep our browser compatibility checks in forever, doesn't it? Would XMLHttpRequest() initialize quicker than ActiveXObject("Microsoft.XMLHTTP") or what? Why would Microsoft add it and make it optional?

推荐答案

还可以禁用ActiveXObject.请注意,其他浏览器也可以禁用此设置和其他设置.这与浏览器的兼容性无关,而与用户的偏好有关.用户可以允许/禁止跨域请求,可以允许/禁止脚本,可以允许或不允许Flash等.

The ActiveXObject can also be disabled. Note that other browsers can disable this and other settings as well. This is not about browser compatibility, but about user preference. Users can allow / disallow cross-domain requests, can allow / disallow scripts, can allow Flash or not etc.

当用户禁用了所需的某些浏览器功能时,您始终必须检查页面是否仍然流畅运行(或正常回退).

You'll always have to check whether your page still runs smooth (or falls back gracefully) when users have disabled certain browser's features that you need.

好消息是:默认情况下启用了此功能,大多数用户都将其启用.

The good news is: it is enabled by default, most users will have it on.

更新:默认情况下,脚本和外部请求(即带有XSLT的 document() xsl:include 或XML的外部实体)XcodeHttpRequest 检索的对象不支持,并且必须显式启用.这与非IE浏览器不同,非IE浏览器允许来自 XHR 加载的文档的外部请求(或者不存在,例如Safari和Chrome).

Update: by default, scripting and external requests (i.e. document(), xsl:include with XSLT or external entities in XML) are not supported by XmlHttpRequest-retrieved objects and must be enabled explicitly. This is different from non-IE browsers, where external requests from XHR-loaded documents are allowed (or don't exist, like in Safari and Chrome).

这篇关于XMLHttpRequest()与ActiveXObject(& quot; Microsoft.XMLHTTP& quot;)-重点是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆