本文介绍了在AngularJS设置window.location或window.open给人"访问被拒绝"在IE 11的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我承认一个AngularJS新手,但我找不到为什么code在Chrome和Firefox的作​​品,但给人访问被拒绝在JavaScript控制台IE 11。

I'm admittedly an AngularJS newbie but I can't find why this code works in Chrome and Firefox but gives "Access is denied" in the javascript console with IE 11.

我需要通过身份验证的REST调用来显示PDF。理想的应该显示在弹出(preVIEW)一种窗口。

I need to display a PDF via an authenticated REST call. Ideally this would be displayed in a popup (preview) kind of window.

code到目前为止是这样的:

Code thus far looks like:

$http.post( url, payload, {
    headers : {
        "Authorization": token
    },
    responseType: "arraybuffer"
}).success(function ( data ) {
    var file = new Blob( [ data ], { type: 'application/pdf' });
    var fileURL = URL.createObjectURL( file );
    window.open( fileURL );
}

window.open()给出了IE11的访问被拒绝消息,但在Chrome工作和Firefox。我试着更改为 window.location的(),并得到了同样的错误。

The window.open() gives the "access is denied" message for IE11, but works in Chrome and Firefox. I tried changing to window.location(), and got the same error.

这是不是一个跨域问题(一切都在同一个foo.net域)。

This isn't a cross-domain issue (everything is in the same foo.net domain).

推荐答案

Saving文本在Internet Explorer 10 本地文件

它看起来像斑点IE块window.open,但实现自己的功能打开和保存斑点。相反,尝试

It looks like IE blocks window.open on blobs, but implemented their own functions for opening and saving blobs. Instead try

if (window.navigator && window.navigator.msSaveOrOpenBlob) {
    window.navigator.msSaveOrOpenBlob(blob);
}
else {
    var objectUrl = URL.createObjectURL(blob);
    window.open(objectUrl);
}

这篇关于在AngularJS设置window.location或window.open给人"访问被拒绝"在IE 11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-27 03:04
查看更多