如何在新窗口打开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()
相关推荐
耀耀切克闹灬3 分钟前
短链跳转
前端
孟陬7 分钟前
高质量全方位的 AI 工具 sse-stuntman — Mock SSE 接口
前端·node.js·openai
Cao_Ron10 分钟前
给 ECharts 6 graph 节点叠加角标:从原理到性能优化
前端
WebGirl24 分钟前
内网穿透方式
前端
hoLzwEge1 小时前
前端项目的基石:深入解读 package.json 的作用与核心配置
前端·前端框架
奇奇怪怪的1 小时前
Agentic RAG:Agent 驱动的自主检索
前端
陆枫Larry1 小时前
页面接口换图后不刷新,刷新页面后才看得到新图
前端
0x861 小时前
# Flutter 实时语音识别工程实践:从音频采集到流式 ASR 的完整链路
前端
Patrick_Wilson1 小时前
从一次 Safari 白屏,聊聊 CDN 外置 React 的坑与前端监控盲区
前端·react.js·cdn
lichenyang4532 小时前
从 Demo 到本地 HAR 包:把 HarmonyOS JSBridge 运行时做成可复用库
前端