業余奶茶品鑒師
2017-12-04 11:12:54
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
提交
取消