如何使用JavaScript将弹出窗口置于屏幕中央?
要将弹出窗口置于屏幕中央,您可以尝试运行以下代码
示例
<!DOCTYPE html>
<html>
<body>
<script>
function myPopup(myURL, title, myWidth, myHeight) {
var left = (screen.width - myWidth) / 2;
var top = (screen.height - myHeight) / 4;
var myWindow = window.open(myURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' + myWidth + ', height=' + myHeight + ', top=' + top + ', left=' + left);
}
</script>
<button onclick=" myPopup ('http://www.qries.com', 'web', 1050, 550);">Open Qries.com</button>
</body>
</html>热门推荐
10 布置会场生日祝福语简短
11 女生高级生日祝福语简短
12 工作心愿文案祝福语简短
13 经典疫情祝福语大全简短
14 小孩想说的祝福语简短
15 祝福语同事离职英文简短
16 送给同桌的祝福语简短
17 新年送老师简短祝福语
18 求婚祝福语独特简短英文