如何在新窗口打开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 小时前
ahooks useMemoizedFn:解决 useCallback 的依赖地狱
java·javascript
mCell9 小时前
【短文】不是最强,是最适合
前端·aigc·deepseek
余瑜鱼鱼鱼10 小时前
HTML常用标签总结
前端·html
Jave210810 小时前
Vue 中 mixins 混合开发的主要使用场景有哪些?
前端·vue.js
徐同保11 小时前
openclaw安装
前端
JEECG低代码平台11 小时前
JeecgBoot低代码平台 Ant Design Vue 4.x 升级避坑指南
前端·vue.js·低代码
yashuk11 小时前
Go-Gin Web 框架完整教程
前端·golang·gin
唐叔在学习11 小时前
e.preventDefault()到底怎么用?
前端·javascript
北寻北爱11 小时前
面试题-vue篇
前端·vue.js
XPoet11 小时前
AI 编程工程化:Skill——给你的 AI 员工装上技能包
前端·后端·ai编程