javascript AngularJS 中的 IE11 拒绝访问
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28740949/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Access is Denied on IE11 in AngularJS
提问by Sandy
Every development pipeline has 2 parts. FIRST to work hard and develop the application. SECOND to work harder and make it compatible with the great arrogant IE.
每个开发管道都有 2 个部分。首先努力工作并开发应用程序。第二要更加努力,让它与傲慢的IE兼容。
We have an AngularJS (v1.3.13)
application without any server side code developed in Webstorm
. We are making REST
calls to service. Our application works fine on Chrome and Firefox without any Console errors. However when we try to open the page in IE11 or IE9 (not tried IE10), our page doesn't load. Console suggests we have 2 errors. One of them is Access is Denied
on
我们有一个AngularJS (v1.3.13)
没有任何服务器端代码的应用程序在Webstorm
. 我们正在REST
拨打服务电话。我们的应用程序在 Chrome 和 Firefox 上运行良好,没有任何控制台错误。但是,当我们尝试在 IE11 或 IE9(未尝试过 IE10)中打开页面时,我们的页面无法加载。控制台提示我们有 2 个错误。其中之一Access is Denied
在
xhr.open(method, url, true);
in angular.js
.
在angular.js
.
There are number of posts on internet and none seems to be working. This is what I have tried.
互联网上有很多帖子,但似乎没有一个有效。这是我尝试过的。
- Hosting app in
IIS
with changed Handler Mappings to support Cross Domain calls on an Application pool of.Net v4.0
(as suggested by a Senior) - Tried to disable to cache for HTTP requests.
- Adding Domain in trusted site category and also adding locahost/IP to local intranet.
- Changing request type to
JSONP
and trying to addAccess-Control-Allow-Origin
(with value of*
) to headers. - Changing IE settings to allow Cross Domain calls.
IIS
使用更改的处理程序映射托管应用程序以支持应用程序池上的跨域调用.Net v4.0
(如高级建议)- 试图禁用缓存 HTTP 请求。
- 在受信任的站点类别中添加域,并将 locahost/IP 添加到本地 Intranet。
- 将请求类型更改为
JSONP
并尝试将Access-Control-Allow-Origin
(值为*
)添加到标头。 - 更改 IE 设置以允许跨域调用。
Error is still chasing us. Even my colleagues have tried the same on their machines ending up with similar blow. Is there anyone to suggest me something on this.
错误仍在追赶我们。甚至我的同事也曾在他们的机器上尝试过同样的方法,但最终也受到了类似的打击。有没有人向我建议这方面的事情。
It may be CORS and I may need to go for xdr (XDomainRequest) but not sure how to use it as error is in angular.js. I am certainly no expert on this so please suggest.
它可能是 CORS,我可能需要使用 xdr (XDomainRequest) 但不确定如何使用它,因为 angular.js 中的错误。我当然不是这方面的专家,所以请提出建议。
Screen shot of the error:
错误截图:
IE shows another error:
[$injector:nomod] Module 'ngLocale' is not available!
You either misspelled the module name or forgot to load it.
If registering a module ensure that you specify the dependencies
as the second argument.
http://errors.angularjs.org/1.2.16/$injector/nomod?p0=ngLocale
which I am ignoring for now.
IE 显示另一个错误:
[$injector:nomod] Module 'ngLocale' is not available!
You either misspelled the module name or forgot to load it.
If registering a module ensure that you specify the dependencies
as the second argument.
http://errors.angularjs.org/1.2.16/$injector/nomod?p0=ngLocale
我现在忽略它。
Please suggest me something on this. Thanks.
请给我建议。谢谢。
回答by user2150902
I switched from 1.3.4 to 1.4.8 and that did the trick. No more Angular Access Denied in I.E. (Microsoft Edge 25 2015). I don't know why.
我从 1.3.4 切换到 1.4.8 就成功了。IE 中不再有 Angular Access Denied (Microsoft Edge 25 2015)。我不知道为什么。
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.8/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-route.js/1.4.8/angular.min.js"></script>
回答by SURENDRANATH SONAWANE
Access is Denied on IE11 in AngularJS error have a solution on this linkI also got the same error while downloading Image from IE11. I have just added the following line in my code and It works.
Access is Denied on IE11 in AngularJS error has a solution on this link我在从 IE11 下载图像时也遇到了同样的错误。我刚刚在我的代码中添加了以下行并且它有效。
window.navigator.msSaveBlob(blob, paramDataObject.fileName);
or
window.navigator.msSaveOrOpenBlob(blob, paramDataObject.fileName);
回答by JungTae
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
window.navigator.msSaveOrOpenBlob(blob);
}
else {
var objectUrl = URL.createObjectURL(blob);
window.open(objectUrl);
}
Setting window.location or window.open in AngularJS gives "access is denied" in IE 11
在 AngularJS 中设置 window.location 或 window.open 在 IE 11 中给出“访问被拒绝”
回答by webdev5
Have you tried xdomain? https://github.com/jpillora/xdomainit's a pure javascript CORS alternative.
你试过xdomain吗?https://github.com/jpillora/xdomain这是一个纯 javascript CORS 替代方案。