如何在新窗口打开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()
相关推荐
*且听风吟18 分钟前
html 实现鼠标滑动点亮横轴
前端·javascript·html
985小水博一枚呀25 分钟前
【AI大模型学习路线】第三阶段之RAG与LangChain——第十九章(实战基于Advanced RAG的PDF问答)系统部署与测试?
人工智能·学习·langchain·pdf
iCoding912 小时前
前端分页 vs 后端分页:技术选型
前端·后端·系统架构
mingtianyihou332 小时前
使用 Service Worker 限制请求并发数
前端
张可爱2 小时前
20251017-Vue2八股文整理(上篇)
前端
FanetheDivine2 小时前
ts中如何描述一个复杂函数的类型
前端·typescript
lightgis2 小时前
chrome中的axure插件提示无法不受支持
前端·chrome
速易达网络2 小时前
Vue3 原生移动应用开发来了
前端·javascript·css
渣哥2 小时前
别再乱用了!Spring AOP 与 AspectJ 的区别比你想的复杂
javascript·后端·面试
GISer_Jing2 小时前
LLM对话框项目技术栈&重难点总结
前端·ai·node.js