javascript - 如何设置在浏览器的新标签(_blank)中打开的pdf文件的标题
问题描述
这是我的尝试,它是否在 newtab 上打开,但它总是显示test 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();
}
推荐阅读
- angular - 动态添加和删除组件作为 Angular 中的表单字段
- reactiveui - 如何在类的设置器之外更改属性时发出 ReactiveUI WhenAnyValue
- python - 如何将参数传递给多处理循环
- r - 咕噜声找到最小值,然后用 case_when 标记
- animation - SVG feColorMatrix 动画在 Safari 中不起作用,在 Chrome 和 Firefox 中正常
- html - 没有流式传输的 HTML 视频
- ruby-on-rails - 在同一个 Rails 模型中创建孙子关联
- ag-grid - 如何让 datepicker 在全行编辑模式下使用 ag-grid-react
- python-3.x - Replacing values in a dataframe from a list
- swift - 致命错误:对类 '__lldb_expr_1.B' 使用未实现的初始化程序 'init(...)'