// 使用 window.open() 方法可以打开一个新的浏览器窗口或标签页
function openNewWindow(url) {
// 参数 url 是新窗口要加载的页面地址
// 如果不提供 url,则会打开一个空白的新窗口
window.open(url, '_blank');
}
// 示例:打开百度首页在新窗口中
openNewWindow('https://www.baidu.com');
// 如果需要自定义新窗口的大小和特性,可以在 window.open 的第三个参数中指定
function openCustomWindow(url, width, height) {
let left = (screen.width/2)-(width/2);
let top = (screen.height/2)-(height/2);
let options = `status=no,height=${height},width=${width},top=${top},left=${left}`;
window.open(url, '_blank', options);
}
// 示例:打开百度首页在自定义大小的新窗口中
openCustomWindow('https://www.baidu.com', 800, 600);
上一篇:js 获取页面宽度
下一篇:js 获取滚动条高度
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站