如何控制弹窗页面的body标签大小

要控制弹窗页面的body标签的大小,可以通过添加样式来设置。

方法一:在body标签中添加style属性

在代码中的弹窗页面的body标签上添加style属性,设置样式。

例如:<body style='width: 500px; height: 300px;'>

方法二:使用JavaScript代码添加样式

使用JavaScript代码来添加样式。

例如:

let body = window.open(url).document.body;
body.style.width = '500px';
body.style.height = '300px';

以上代码将弹窗页面的body标签的宽度设置为500px,高度设置为300px。你可以根据需要自行调整宽高的数值。

示例代码:

let base = data.rxFile;
let bstr = atob(base);
let n = bstr.length;
let u8arr = new Uint8Array(n);
while (n--) {
  u8arr[n] = bstr.charCodeAt(n);
}
let blob = new Blob([u8arr], {type: 'application/pdf;chartset=UTF-8'});
let url = window.URL.createObjectURL(blob);
let newWindow = window.open(url);
let body = newWindow.document.body;
body.style.width = '500px';
body.style.height = '300px';
// window.open(url)
// const a = document.createElement('a')
// a.href = url
// //不下载 a.download = name + '.pdf'
// document.body.appendChild(a)
// a.click()
// document.body.removeChild(a)
//删除url绑定
window.URL.revokeObjectURL(url)
如何控制弹窗页面的body标签大小

原文地址: https://www.cveoy.top/t/topic/cVGS 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录