加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ajax – XDomainRequest可以使用SSL吗?

发布时间:2020-12-16 03:09:05 所属栏目:百科 来源:网络整理
导读:我有在IE8中使用Microsoft的XDomainRequest对象的代码。代码如下所示: var url = "http://host/api/acquire?query string"; var xdr = new XDomainRequest(); xdr.onload = function(){ $.("#identifier").text(xdr.responseText); }; xdr.open("GET",url);
我有在IE8中使用Microsoft的XDomainRequest对象的代码。代码如下所示:
var url = "http://<host>/api/acquire?<query string>";  
var xdr = new XDomainRequest();  
xdr.onload = function(){  
    $.("#identifier").text(xdr.responseText);  
};  
xdr.open("GET",url);  
xdr.send();

当“url”中的方案为“http://”时,命令工作正常。但是,当方案是“https://”IE8给我一个“访问被拒绝”JavaScript错误。这两种方案在FF 3.6.3中都可以正常工作,当然,我使用XmlHttpRequest。使用两个浏览器,我都遵守W3C访问控制。 “http://”对于这两种浏览器都是跨原产地。所以问题是IE8,XDomainRequest和SSL。

SSL证书不是问题。如果我在IE8的地址栏中输入https://< host> /,其中< host>与上面的“url”相同,页面加载正常。

所以我们有以下几点:
– 直接从浏览器中点击https://< host> /
– 点击https://< host> / api / acquire?< query string>通过XDomainRequest不允许。

可以做吗我要离开吗?

显然,答案在这里: http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx

本页上的第7点说,“请求必须与托管页面相同的方案”。

以下是第7点的一些支持文本:

“It was definitely our intent to prevent HTTPS pages from making
XDomainRequests for HTTP-based resources,as that scenario presents a
Mixed Content Security Threat which many developers and most users do
not understand.

However,this restriction is overly broad,because it prevents HTTP
pages from issuing XDomainRequests targeted to HTTPS pages. While it’s
true that the HTTP page itself may have been compromised,there’s no
reason that it should be forbidden from receiving public resources
securely.”

目前看来,我原来的问题的答案是:是的,如果主机页面可以使用“https://”方案;不,如果不行。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读