繁体   English   中英

如何在浏览器的新标签页(_blank)中设置打开pdf文件的标题

[英]How to set title for pdf file opening in new tab (_blank) in browser

这是我的尝试,是否已在newtab上打开,但始终显示测试pdf作为标题

function titlepath(path,name){
    alert(path);
    alert(name);
    document.title = name;
    window.open(path, '_blank');
}

这个解决方案对我有用。 问题:如何在新打开的选项卡中更改pdf的标题

     function titlepath(path,name){

        //In this path defined as your pdf url and name (your pdf 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();
        }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM