如何在新窗口打开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()
相关推荐
米丘9 小时前
React 19.x 的 lazy 与 Suspense
前端·javascript·react.js
如果超人不会飞9 小时前
TinyVue Grid 表格 fetchData 完全指南:从入门到精通
前端
kyriewen9 小时前
手写虚拟DOM后,我反问面试官:key为什么不能用index?
前端·react.js·面试
Doris_20239 小时前
说一说ESLint+Prettier生效的原理
前端·设计模式·架构
ZC跨境爬虫10 小时前
跟着 MDN 学CSS day_21:(图像溢出控制与表单元素样式定制)
前端·javascript·css·ui·交互
卷帘依旧10 小时前
微前端解决方案-qiankun
前端
moshuying10 小时前
你做的,比汇报出来的多得多
前端
shuye21610 小时前
google chrome 离线下载地址
前端·chrome
yqcoder10 小时前
闭包是什么?优缺点、怎么防内存泄漏?
前端·http
riuphan10 小时前
JavaScript 中的 this 关键字
javascript