JavaScript 打开小窗口的实现方法
📅 2026/7/14 8:48:50
👁️ 阅读次数
📝 编程学习
function openCenteredWindow(url ) { const width = 600; const height = 400; // 计算居中位置 const left = Math.round((screen.width - width) / 2); const top = Math.round((screen.height - height) / 2); window.open( url, "_blank", `width=${width},height=${height},left=${left},top=${top},toolbar=no,location=no` ); } const url = "https://example.com"; openCenteredWindow(url)
编程学习
技术分享
实战经验