如何在新窗口打开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()
相关推荐
KaMeidebaby5 小时前
卡梅德生物技术快报|PD1 单克隆抗体定制配套 N 糖全谱质控开发
前端·人工智能·算法·数据挖掘·数据分析
nuIl6 小时前
实现一个 Coding Agent(3):工具调用
前端·agent·cursor
nuIl6 小时前
实现一个 Coding Agent(4):ReAct 循环
前端·agent·cursor
nuIl6 小时前
实现一个 Coding Agent(1):一次 LLM 调用
前端·agent·cursor
nuIl6 小时前
实现一个 Coding Agent(2):让 LLM 流式响应
前端·agent·cursor
copyer_xyf6 小时前
Python 异常处理
前端·后端·python
sugar__salt7 小时前
从栈队列数据结构到JS原型面向对象全解
前端·javascript·数据结构
MageGojo7 小时前
随机文案模块怎么做?从接口封装到前端展示的完整实现思路
javascript·前端开发·api接口·后端开发·随机文案
独特的螺狮粉7 小时前
篮球集训班器具管理系统 - 鸿蒙PC Electron框架完整技术实现指南
前端·javascript·华为·electron·前端框架·开源·鸿蒙
小妖6667 小时前
js 生成随机数技巧 Math.random().toString(36)
javascript·随机数