ย้ายหน้าต่างโดย()
ตัวอย่าง
เปิดหน้าต่างใหม่และย้าย 250px โดยสัมพันธ์กับตำแหน่งปัจจุบัน:
function openWin()
{
myWindow = window.open('', '', 'width=400, height=400');
}
function moveWin()
{
myWindow.moveBy(250, 250);
}
ตัวอย่างเพิ่มเติมด้านล่าง
ความหมายและการใช้งาน
วิธี การmoveBy()
ย้ายหน้าต่างจำนวนพิกเซลที่สัมพันธ์กับพิกัดปัจจุบัน
ไวยากรณ์
window.moveBy(x, y)
พารามิเตอร์
Parameter | Description |
x | Required. A positive or negative number. The number of pixels to move the window horizontally. |
y | Required. A positive or negative number. The number of pixels to move the window vertically. |
คืนมูลค่า
ไม่มี |
ตัวอย่างเพิ่มเติม
ใช้ moveBy() ร่วมกับ moveTo():
function moveWinTo() {
myWindow.moveTo(150, 150);
}
function moveWinBy() {
myWindow.moveBy(75, 75);
}
รองรับเบราว์เซอร์
moveBy()
รองรับในทุกเบราว์เซอร์:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |