如何在新窗口打开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()
相关推荐
多来哈米几秒前
Jenkins配置vue前端项目(最简单的操作)
运维·前端·jenkins
一只叁木Meow1 分钟前
Vue scoped CSS 与 Element Plus Drawer 样式失效问题深度解析
前端
用户92426257007311 分钟前
Vue 学习笔记:组件通信(Props / 自定义事件)与插槽(Slot)全解析
前端
Zyx20072 分钟前
JavaScript 数组:从内存布局到遍历策略的深度解析
javascript
UIUV3 分钟前
Ajax 数据请求学习笔记
前端·javascript·代码规范
FogLetter4 分钟前
手写useInterval:告别闭包陷阱,玩转React定时器!
前端·react.js
神秘的猪头5 分钟前
Vibe Coding 实战教学:用 Trae 协作开发 Chrome 扩展 “Hulk”
前端·人工智能
小时前端6 分钟前
当递归引爆调用栈:你的前端应用还能优雅降落吗?
前端·javascript·面试
盼小辉丶6 分钟前
TensorFlow深度学习实战(43)——TensorFlow.js
javascript·深度学习·tensorflow
张可爱7 分钟前
20251112-问题排查与复盘
前端