ปรับขนาดหน้าต่างโดย()
ตัวอย่าง 1
เปิดหน้าต่างใหม่และปรับขนาด (เพิ่ม) ความกว้างและความสูง:
function openWin() {
myWindow = window.open("", "", "width=100, height=100");
}
function resizeWin() {
myWindow.resizeBy(250, 250);
}
ตัวอย่างเพิ่มเติมด้านล่าง
ความหมายและการใช้งาน
วิธี การresizeBy()
ปรับขนาดหน้าต่างตามจำนวนที่ระบุ
ไวยากรณ์
resizeBy(width, height)
พารามิเตอร์
Parameter | Description |
width | Required. A positive or a negative number. The number of pixels to resize the width by. |
height | Required. A positive or a negative number. The number of pixels to resize the height by. |
คืนมูลค่า
ไม่มี |
ตัวอย่างเพิ่มเติม
เปิดหน้าต่างใหม่ และลดความกว้างลง 50px และเพิ่มความสูงขึ้น 50px:
myWindow.resizeBy(-50, 50);
ใช้ resizeBy() กับ resizeTo():
function resizeWinTo() {
myWindow.resizeTo(800, 600);
myWindow.focus();
}
function resizeWinBy() {
myWindow.resizeBy(-100, -50);
}
รองรับเบราว์เซอร์
resizeBy()
รองรับในทุกเบราว์เซอร์:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |