Javascript 打开pdf时打开的窗口不在Chrome中工作

Javascript 打开pdf时打开的窗口不在Chrome中工作,javascript,pdf,Javascript,Pdf,我使用下面的代码在窗口中打开pdf。打开动态标题的pdf 此代码运行正常,但在Chrome浏览器中无法运行 我看到pdf的标题打开时,但pdf未打开 function titlepath(path,name) { var prntWin = window.open(); prntWin.document.write("<html><head><title>"+name+"</title></head><body>"

我使用下面的代码在窗口中打开pdf。打开动态标题的pdf

此代码运行正常,但在Chrome浏览器中无法运行

我看到pdf的标题打开时,但pdf未打开

function titlepath(path,name)
{
  var prntWin = window.open();
  prntWin.document.write("<html><head><title>"+name+"</title></head><body>"
  + '<embed width="100%" height="100%" name="plugin" src="'+path+'" '
  + 'type="application/pdf" internalinstanceid="21"></body></html>');
  prntWin.document.close();
}
函数标题路径(路径、名称)
{
var prntWin=window.open();
prntWin.document.write(“+name+”)
+ '');
prntWin.document.close();
}

假设相同的协议和可能相同的来源

注意:假设PDF也来自网站,因为从文件系统加载时可能会遇到问题

注意:如果服务器发送,可能不允许您显示

试试iFrame

function titlepath(path,name) {
  var prntWin = window.open("");
  prntWin.document.write("<html><head><title>"+name+"</title></head><body>" + 
  '<iframe width="100%" height="100%" name="plugin" src="'+path+'"></iframe></body></html>');
  prntWin.document.close();
}
函数标题路径(路径、名称){
var prntWin=window.open(“”);
prntWin.document.write(“+name+”)+
'');
prntWin.document.close();
}
或者至少关闭嵌入式系统

function titlepath(path,name) {
  var prntWin = window.open("");
  prntWin.document.write("<html><head><title>"+name+"</title></head><body>" +
  '<embed width="100%" height="100%" name="plugin" src="'+path+'"></embed>'+
  '</body></html>');
  prntWin.document.close();
}
函数标题路径(路径、名称){
var prntWin=window.open(“”);
prntWin.document.write(“+name+”)+
''+
'');
prntWin.document.close();
}

您的问题中没有jQuery。我重新标记了它,并从问题中删除了jQuery。这很简单。您是否在控制台中遇到任何错误,例如,如果您使用的是HTTPS,而PDF位于另一个源上,或者使用的是HTTPS,
'type=“application/PDF”
在嵌入式系统上做什么?另外,请尝试使用iFrame instead检查浏览器是否在地址栏中抛出任何警告?@mplungjan No没有任何错误。但当在新窗口中打开pdf时,url中的“about:blank”就是这样。你能在chrome上打开pdf吗?请尝试打开任何其他pdf文件,看看是否与您的chrome设置有关。您好,此代码在mozila中运行良好,但在chrome浏览器中的工作方式与我的代码不同。如果您这样做,chrome不允许加载本地资源。@mplungjan无效。我也在服务器上添加了这段代码,但在服务器上也存在同样的问题。