Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/452.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用_blank时从$http.post崩溃打开PDF_Javascript_Angularjs - Fatal编程技术网

Javascript 使用_blank时从$http.post崩溃打开PDF

Javascript 使用_blank时从$http.post崩溃打开PDF,javascript,angularjs,Javascript,Angularjs,我向WS发布帖子并接收PDF,我将其转换为blob,创建URL并打开它 如果我在'u self'中打开pdf,它会工作!我看到了pdf。 我还可以创建一个下载元素的链接,它也可以工作! 但是如果我在“空白”中打开pdf,就会创建一个新选项卡并立即关闭 这是我的密码: getDoc(id) { const url = 'url'; this.$http.post( url, { data: { id, }, }, {

我向WS发布帖子并接收PDF,我将其转换为blob,创建URL并打开它

如果我在'u self'中打开pdf,它会工作!我看到了pdf。 我还可以创建一个下载元素的链接,它也可以工作! 但是如果我在“空白”中打开pdf,就会创建一个新选项卡并立即关闭

这是我的密码:

getDoc(id) {
  const url = 'url';
  this.$http.post(
    url,
    {
      data: {
        id,
      },
    },
    {
      responseType: 'arraybuffer',
    }).then((response) => {
      const blob = new Blob([response.data], { type: 'application/pdf;' });
      const urlPdf = this.$window.URL.createObjectURL(blob);
      const win = this.$window.open(urlPdf, '_blank');
      win.focus();
    });
}
我是否必须添加一些内容才能在新选项卡/窗口中打开它

为什么它适用于“你自己”而不是“空白”


谢谢大家!

我启用了adblock,这就是问题所在,一旦禁用,pdf现在可以使用_blank


谢谢你的评论

确保你没有一些广告/弹出窗口拦截器-我有一个类似的问题哦哇,广告拦截器正在关闭它!你是对的!你能把它作为答案贴出来让我接受吗?非常感谢。请自己回答这个问题,因为我并没有真正解决任何问题,这只是一个建议:)很乐意帮忙