Javascript 打印功能在IE 11中抛出一个错误,表示访问被拒绝,但在Chrome上使用localhost时没有问题

Javascript 打印功能在IE 11中抛出一个错误,表示访问被拒绝,但在Chrome上使用localhost时没有问题,javascript,printing,internet-explorer-11,Javascript,Printing,Internet Explorer 11,这是我的代码: const height = document.documentElement.clientHeight; const width = document.documentElement.clientWidth; const title = 'One-time payment - Billing'; const printWin = window.open(title, title, `width=${width},height=${height},

这是我的代码:

    const height = document.documentElement.clientHeight;
    const width = document.documentElement.clientWidth;
    const title = 'One-time payment - Billing';
    const printWin = window.open(title, title, `width=${width},height=${height},menubar=no,location=no,resizable=no,scrollbars=no`);
    if (!printWin) {
      return;
    }
    printWin.focus();
    printWin.document.title = title;
    printWin.document.write(`<title>${title}</title>`);
const height=document.documentElement.clientHeight;
常量宽度=document.documentElement.clientWidth;
const title=‘一次性付款-账单’;
const printWin=window.open(title,title,`width=${width},height=${height},menubar=no,location=no,resizeable=no,scrollbars=no`);
如果(!printWin){
返回;
}
printWin.focus();
printWin.document.title=标题;
printWin.document.write(`${title}`);
当我点击打印按钮时,它会打开一个带有打印预览的窗口,然后让用户打印,这在Chrome上非常有效,但在IE 11上却不行。 在IE 11上,它抛出一个错误,表示访问被拒绝,并打开一个带有404错误的新窗口

我还在StorybookLocalHost上运行此代码


有人能帮忙吗

我在IE 11中尝试了你的代码,当我使用``而不是“”,它会给我一个无效字符的错误,因为IE 11不支持模板文本。 请尝试将代码更改为此,以查看是否可以管理它以使其正常工作:

window.open(title, title, "width="+width+",height="+height+",menubar=no,location=no,resizable=no,scrollbars=no");
以及:

printWin.document.write(“+title+”);

well IE11不支持模板文本,因此我预计会出现另一个错误。请检查相关文件夹是否具有访问相关js文件的权限?下面是一些关于拒绝访问错误的相关文章,您可以参考它们:,我只是尝试进行这些更改并进行了检查,但它仍然抛出相同的错误,并且窗口作为错误404页面打开。您还有其他建议吗?我在问题中包含了控制台日志的屏幕截图,如果这对您访问控制台(点击F12)有任何帮助,您是否看到任何其他错误可以帮助我们了解发生了什么?404错误只是在代码试图访问一些不存在的页面/资源时才有意义。正如我所看到的,您的代码在bundle.js中被缩小了,似乎存在权限错误,可能您是在公司环境中开发的,并且某些规则正在阻止main中的某些代码。js是的,您是对的,但同样的代码也适用于Chrome,但不适用于IE11。请让我知道是否有解决此问题的方法
printWin.document.write("<title>"+title+"</title>");