window.open() 设置弹出窗的位置时,距离左侧的距离总是不生效,这是为什么啊?如下面的代码,点击按钮一,弹出百度的窗口,设置的top=200生效,但left=400不生效。点击按钮二,弹出百度的窗口,设置的a.moveTo(400, 200)X坐标上的距离也不生效。<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
body {
padding:50px;
}
span {
padding: 20px 40px;
background: pink;
}
</style>
</head>
<body>
<span onclick="openW1()">按钮一</span>
<span onclick="openW2()">按钮二</span>
</body>
<script>
function openW1() {
window.open('https://www.baidu.com', '_blank', 'width=800,height=600,top=200,left=400')
}
function openW2() {
var a = window.open('https://www.baidu.com', '_blank', 'width=800,height=600')
a.moveTo(400, 200)
}
</script>
</html>
添加回答
举报
0/150
提交
取消