Cửa sổ di chuyểnTo()
Ví dụ
Mở một cửa sổ mới và di chuyển nó đến vị trí 500 x 100:
function openWin()
{
myWindow = window.open('', '', 'width=400, height=200');
}
function moveWin()
{
myWindow.moveTo(500, 100);
}
Hãy tự mình thử »Thêm ví dụ dưới đây.
Sự miêu tả
Phương thức moveTo()
di chuyển một cửa sổ tới tọa độ đã chỉ định.
Xem thêm:
Cú pháp
window.moveTo( x, y )
Thông số
Parameter | Description |
x | Required. A positive or negative number. The horizontal coordinate to move to. |
y | Required. A positive or negative number. The vertical coordinate to move to. |
Giá trị trả về
KHÔNG CÓ |
Thêm ví dụ
Sử dụng moveTo() cùng với moveBy():
function moveWinTo() {
myWindow.moveTo(150, 150);
}
function moveWinBy() {
myWindow.moveBy(75, 50);
}
Hãy tự mình thử »Hỗ trợ trình duyệt
moveTo()
được hỗ trợ trong tất cả các trình duyệt:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |