如何在新窗口打开pdf文件,并修改网页标题

一、使用iframe打开

复制代码
newWindow.document.title = "新页面标题";
const iframe = newWindow.document.createElement('aaa')
iframe.src = url; // 你想要加载的URL
iframe.width = '100%';
iframe.height = '100%';
newWindow.document.body.appendChild(iframe);

二、使用embed标签

复制代码
 const blob = new Blob([res.data], { type: 'application/pdf' })
 const url = URL.createObjectURL(blob)
 const newWindow = window.open('', '_blank')
 if (newWindow) {
      newWindow.document.write(`
          <html>
            <head>
              <title>考核比例参照表</title>
            </head>
            <body>
              <embed src="${url}" type="application/pdf" width="100%" height="100%">
            </body>
          </html>
        `)
  newWindow.document.close()
相关推荐
程序员清洒1 小时前
Flutter for OpenHarmony:GridView — 网格布局实现
android·前端·学习·flutter·华为
VX:Fegn08951 小时前
计算机毕业设计|基于ssm + vue超市管理系统(源码+数据库+文档)
前端·数据库·vue.js·spring boot·后端·课程设计
0思必得01 小时前
[Web自动化] 反爬虫
前端·爬虫·python·selenium·自动化
LawrenceLan1 小时前
Flutter 零基础入门(二十六):StatefulWidget 与状态更新 setState
开发语言·前端·flutter·dart
秋秋小事2 小时前
TypeScript 模版字面量与类型操作
前端·typescript
2401_892000522 小时前
Flutter for OpenHarmony 猫咪管家App实战 - 添加提醒实现
前端·javascript·flutter
Yolanda942 小时前
【项目经验】vue h5移动端禁止缩放
前端·javascript·vue.js
广州华水科技3 小时前
单北斗GNSS形变监测一体机在基础设施安全中的应用与技术优势
前端
EndingCoder4 小时前
案例研究:从 JavaScript 迁移到 TypeScript
开发语言·前端·javascript·性能优化·typescript
阿珊和她的猫5 小时前
React 路由:构建单页面应用的导航系统
前端·react.js·状态模式