Javascript 使用window.open()打开iframe时,PDF被卡住

Javascript 使用window.open()打开iframe时,PDF被卡住,javascript,pdf,iframe,window.open,Javascript,Pdf,Iframe,Window.open,我正在尝试在新选项卡中以base64格式的字符串形式打开接收到的PDF。它在一个新窗口中打开,没有任何内容,但当我在页面上“检查元素”时,我得到的PDF非常好 这是我的密码- var pdfWindow = window.open("about:blank", "_blank"); pdfWindow.document.write("<iframe width='100%' height='100%' src='data:application/pdf;base64, " + encode

我正在尝试在新选项卡中以base64格式的字符串形式打开接收到的PDF。它在一个新窗口中打开,没有任何内容,但当我在页面上“检查元素”时,我得到的PDF非常好

这是我的密码-

var pdfWindow = window.open("about:blank", "_blank");
pdfWindow.document.write("<iframe width='100%' height='100%' src='data:application/pdf;base64, " + encodeURI(payload)+"'></iframe>");
var pdfWindow=window.open(“about:blank”,“_blank”);
pdfWindow.document.write(“”);
此外,我希望在新选项卡中打开PDF,而不是在新窗口中。在新窗口中打开时,PDF将完全打开

要在新窗口中打开,我使用以下代码-

let pdfWindow = window.open("", '_blank', 'dependent=yes,locationbar=no,scrollbars=no,menubar=no,resizable,screenX=50,screenY=50,width=850,height=800')
pdfWindow.document.write("<iframe width='100%' height='100%' src='data:application/pdf;base64, " + encodeURI(payload)+"'></iframe>");
让pdfWindow=window.open(“,”为空“,”依赖项=yes,位置栏=no,滚动栏=no,菜单栏=no,可调整大小,screenX=50,screenY=50,宽度=850,高度=800”)
pdfWindow.document.write(“”);

这是一个老问题,但可能对其他人有所帮助: 问题在于iframe宽度和高度标记。使用定义的像素,而不是使用百分比。这将解决问题

<iframe width='600px' height='600px' ...> </iframe>