当用户点击按钮时,我向我的服务器发送请求,然后它发回一个pdf base64 .

然后我在一个新选项卡中打开它,但是 Chrome 预览中的下载按钮不起作用,当我点击它时没有任何动作 . 它适用于Firefox .

Chrome预览下载按钮:

Chrome preview download button

定义变量 iframeHtml

let iframeHtml = `<iframe
    id="ManualFrame"
    frameborder="0"
    style="border:0; overflow: hidden; margin: 0; height: 100%"
    allowfullscreen>
</iframe>

<script>
setManualFrame();

function setManualFrame() {
  document.getElementById('ManualFrame').setAttribute('height', screen.height);
  document.getElementById('ManualFrame').setAttribute('width', screen.width);
  document.getElementById('ManualFrame').setAttribute('src', "data:application/pdf;base64,${pdfBase64}");
}
</script>`;

然后在新标签中打开它:

let newWindow = window.open();
newWindow.document.write(iframeHtml);

我测试的Chrome版本:
版本: 67.0.3396.79 (Official Build) (64-bit)
版本: 66.0.3359.181 (Official Build) 32 bits