如何在新窗口打开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()