Window
Window
อินเตอร์เฟซที่แสดงให้เห็นถึงหน้าต่างที่มี {{คำศัพท์ ( "DOM")}} เอกสาร; document
จุดสถานที่ให้บริการไปยังเอกสาร DOMโหลดในหน้าต่างที่ สามารถรับหน้าต่างสำหรับเอกสารที่ระบุได้โดยใช้คุณสมบัติ document.defaultView
(en-US)
ตัวแปรส่วนกลางwindow
ซึ่งเป็นตัวแทนของหน้าต่างที่สคริปต์กำลังทำงานอยู่นั้นสัมผัสกับโค้ด JavaScript
Window
อินเตอร์เฟซที่เป็นบ้านที่มีความหลากหลายของฟังก์ชั่น namespaces วัตถุและการก่อสร้างที่ไม่จำเป็นต้องเกี่ยวข้องโดยตรงกับแนวคิดของหน้าต่างอินเตอร์เฟซผู้ใช้ อย่างไรก็ตามWindow
อินเทอร์เฟซเป็นสถานที่ที่เหมาะสมในการรวมรายการเหล่านี้ที่จำเป็นต้องพร้อมใช้งานทั่วโลก หลายคนเหล่านี้จะถูกบันทึกไว้ในเอกสารอ้างอิง JavaScriptและDOM อ้างอิง
ในเบราว์เซอร์แบบแท็บแต่ละแท็บจะแสดงด้วยWindow
วัตถุของตัวเอง ทั่วโลกที่window
เห็นโดยโค้ด JavaScript ที่ทำงานภายในแท็บหนึ่ง ๆ จะแสดงถึงแท็บที่โค้ดกำลังทำงานอยู่เสมอ อย่างไรก็ตามในเบราว์เซอร์แบบแท็บคุณสมบัติและวิธีการบางอย่างยังคงใช้กับหน้าต่างโดยรวมที่มีแท็บเช่น resizeTo ()
(en-US) และ innerHeight
โดยทั่วไปสิ่งที่ไม่สามารถเกี่ยวข้องกับแท็บจะเกี่ยวข้องกับหน้าต่างแทน
ตัวสร้าง
ดูอินเทอร์เฟซ DOMด้วย
DOMParser
(en-US)DOMParser
สามารถแยก XML หรือแหล่งที่มาของ HTML เก็บไว้ในสตริงเป็น DOM เอกสารDOMParser
ที่ระบุไว้ในDOM แยกและเป็นอันดับรูปภาพ
- ใช้สำหรับสร้าง
HTMLImageElement
(en-US) ตัวเลือก
- ใช้สำหรับสร้าง
HTMLOptionElement
(en-US) StaticRange
(en-US) {{trial_inline}} Read only- ส่งกลับคอนสตรัคเตอร์
StaticRange ()
(en-US) ซึ่งสร้างอ็อบเจกต์StaticRange
(en-US) คนงาน
- ใช้สำหรับสร้างWeb Worker
XMLSerializer
(en-US)- แปลงแผนผัง DOM เป็นซอร์ส XML หรือ HTML
คุณสมบัติ
อินเทอร์เฟซนี้สืบทอดคุณสมบัติจากอินเทอร์เฟซ EventTarget
(en-US) และใช้คุณสมบัติจากมิกซ์อิน WindowOrWorkerGlobalScope
(en-US) และ WindowEventHandlers
(en-US)
โปรดสังเกตว่าคุณสมบัติที่เป็นอ็อบเจกต์ (เช่นสำหรับการลบล้างต้นแบบของอิลิเมนต์ในตัว) จะแสดงรายการไว้ในส่วนแยกต่างหากด้านล่าง
Window.closed
(en-US) Read only- คุณสมบัตินี้ระบุว่าหน้าต่างปัจจุบันปิดอยู่หรือไม่
Window.console
(en-US) Read only- ส่งคืนการอ้างอิงไปยังออบเจ็กต์คอนโซลที่ให้การเข้าถึงคอนโซลการดีบักของเบราว์เซอร์
Window.controllers
(en-US) Read only- ส่งคืนอ็อบเจ็กต์คอนโทรลเลอร์ XUL สำหรับหน้าต่างโครเมี่ยมปัจจุบัน
Window.customElements
(en-US) Read only- ส่งกลับการอ้างอิงถึงออบเจ็กต์
CustomElementRegistry
(en-US) ซึ่งสามารถใช้เพื่อลงทะเบียนองค์ประกอบที่กำหนดเองใหม่และรับข้อมูลเกี่ยวกับองค์ประกอบที่กำหนดเองที่ลงทะเบียนไว้ก่อนหน้านี้ Window.crypto
(en-US) Read only- ส่งคืนวัตถุการเข้ารหัสลับของเบราว์เซอร์
Window.devicePixelRatio
(en-US) Read only- ส่งกลับอัตราส่วนระหว่างพิกเซลจริงและพิกเซลอิสระของอุปกรณ์ในจอแสดงผลปัจจุบัน
Window.document
(en-US) Read only- ส่งคืนการอ้างอิงไปยังเอกสารที่มีหน้าต่าง
Window.DOMMatrix
Read only {{trial_inline}}- ส่งกลับการอ้างอิงถึงออบเจ็กต์
DOMMatrix
(en-US) ซึ่งแสดงถึงเมทริกซ์ 4x4 เหมาะสำหรับการดำเนินการ 2 มิติและ 3 มิติ Window.DOMMatrixReadOnly
Read only {{trial_inline}}- ส่งคืนการอ้างอิงไปยังออบเจ็กต์
DOMMatrixReadOnly
(en-US) ซึ่งแสดงถึงเมทริกซ์ 4x4 เหมาะสำหรับการดำเนินการ 2 มิติและ 3 มิติ Window.DOMPoint
Read only {{trial_inline}}- ส่งกลับการอ้างอิงไปยังออบเจ็กต์
DOMPoint
(en-US) ซึ่งแสดงถึงจุด 2 มิติหรือ 3 มิติในระบบพิกัด Window.DOMPointReadOnly
Read only {{trial_inline}}- ส่งคืนการอ้างอิงไปยังออบเจ็กต์
DOMPointReadOnly
(en-US) ซึ่งแสดงถึงจุด 2 มิติหรือ 3 มิติในระบบพิกัด Window.DOMQuad
Read only {{trial_inline}}- ส่งกลับการอ้างอิงถึงออบเจ็กต์
DOMQuad
(en-US) ซึ่งแสดงถึงออบเจ็กต์รูปสี่เหลี่ยมจัตุรัสนั่นคืออันที่มีสี่มุมและสี่ด้าน Window.DOMRect
Read only {{trial_inline}}- ส่งกลับการอ้างอิงไปยังออบเจ็กต์
DOMRect
(en-US) ซึ่งแสดงถึงสี่เหลี่ยมผืนผ้า Window.DOMRectReadOnly
Read only {{trial_inline}}- ส่งกลับการอ้างอิงไปยังวัตถุ
DOMRectReadOnly
(en-US) ซึ่งแสดงถึงรูปสี่เหลี่ยมผืนผ้า Window.event
(en-US) Read only- ส่งคืนเหตุการณ์ปัจจุบันซึ่งเป็นเหตุการณ์ที่กำลังจัดการโดยบริบทของโค้ด JavaScript หรือ
undefined
หากไม่มีเหตุการณ์ใดที่กำลังจัดการอยู่ ควรใช้ออบเจ็กต์Event
(en-US) ที่ส่งตรงไปยังตัวจัดการเหตุการณ์แทนทุกครั้งที่ทำได้ Window.frameElement
(en-US) Read only- ส่งคืนองค์ประกอบที่ฝังหน้าต่างหรือเป็นโมฆะหากไม่ได้ฝังหน้าต่าง
Window.frames
(en-US) Read only- ส่งคืนอาร์เรย์ของเฟรมย่อยในหน้าต่างปัจจุบัน
Window.fullScreen
(en-US)- คุณสมบัตินี้ระบุว่าหน้าต่างแสดงแบบเต็มหน้าจอหรือไม่
Window.history
(en-US) Read only- ส่งคืนการอ้างอิงไปยังออบเจ็กต์ประวัติ
Window.innerHeight
(en-US) Read only- รับความสูงของพื้นที่เนื้อหาของหน้าต่างเบราว์เซอร์รวมถึงแถบเลื่อนแนวนอนหากแสดงผล
Window.innerWidth
(en-US) Read only- รับความกว้างของพื้นที่เนื้อหาของหน้าต่างเบราว์เซอร์รวมถึงแถบเลื่อนแนวตั้งหากแสดงผล
Window.isSecureContext
(en-US) {{trial_inline}} Read only- ระบุว่าบริบทสามารถใช้คุณลักษณะที่ต้องการบริบทที่ปลอดภัยได้หรือไม่
Window.length
(en-US) Read only- ส่งคืนจำนวนเฟรมในหน้าต่าง โปรดดู
window.frames
(en-US) ด้วย Window.location
(en-US)- รับ / ตั้งค่าตำแหน่งหรือ URL ปัจจุบันของวัตถุหน้าต่าง
Window.locationbar
(en-US) Read only- ส่งคืนวัตถุแถบตำแหน่งซึ่งสามารถสลับการเปิดเผยในหน้าต่างได้
Window.localStorage
(en-US) Read only- ส่งคืนการอ้างอิงไปยังออบเจ็กต์หน่วยเก็บข้อมูลในเครื่องที่ใช้ในการจัดเก็บข้อมูลที่สามารถเข้าถึงได้โดยต้นทางที่สร้างขึ้นเท่านั้น
Window.menubar
(en-US) Read only- ส่งคืนวัตถุแถบเมนูซึ่งสามารถสลับการมองเห็นได้ในหน้าต่าง
Window.messageManager
- ส่งคืนวัตถุตัวจัดการข้อความสำหรับหน้าต่างนี้
Window.mozInnerScreenX
(en-US) Read only- ส่งกลับพิกัดแนวนอน (X) ของมุมบนซ้ายของวิวพอร์ตของหน้าต่างในพิกัดหน้าจอ ค่านี้รายงานเป็นพิกเซล CSS ดู
mozScreenPixelsPerCSSPixel
ในnsIDOMWindowUtils
สำหรับปัจจัยการแปลงเพื่อปรับให้เข้ากับพิกเซลของหน้าจอหากจำเป็น Window.mozInnerScreenY
(en-US) Read only- ส่งกลับพิกัดแนวตั้ง (Y) ของมุมบนซ้ายของวิวพอร์ตของหน้าต่างในพิกัดหน้าจอ ค่านี้รายงานเป็นพิกเซล CSS ดู
mozScreenPixelsPerCSSPixel
ปัจจัยการแปลงเพื่อปรับให้เข้ากับพิกเซลหน้าจอหากจำเป็น Window.name
(en-US)- รับ / ตั้งชื่อของหน้าต่าง
Window.navigator
(en-US) Read only- ส่งคืนการอ้างอิงไปยังวัตถุเนวิเกเตอร์
Window.opener
(en-US)- ส่งคืนการอ้างอิงไปยังหน้าต่างที่เปิดหน้าต่างปัจจุบันนี้
Window.outerHeight
(en-US) Read only- รับความสูงของด้านนอกของหน้าต่างเบราว์เซอร์
Window.outerWidth
(en-US) Read only- รับความกว้างของด้านนอกของหน้าต่างเบราว์เซอร์
Window.pageXOffset
(en-US) Read only- นามแฝงสำหรับ
window.scrollX
(en-US) Window.pageYOffset
(en-US) Read only- นามแฝงสำหรับ
window.scrollY
(en-US) Window.parent
(en-US) Read only- ส่งคืนการอ้างอิงถึงพาเรนต์ของหน้าต่างหรือเฟรมย่อยปัจจุบัน
Window.performance
(en-US) Read only- ส่งคืนอ็อบเจ็กต์
Performance
(en-US) ซึ่งรวมถึงtiming
(en-US) และnavigation
(en-US) แอตทริบิวต์ซึ่งแต่ละรายการเป็นวัตถุที่ให้ข้อมูลที่เกี่ยวข้องกับประสิทธิภาพ โปรดดูการใช้ Navigation Timingสำหรับข้อมูลเพิ่มเติมและตัวอย่าง Window.personalbar
(en-US) Read only- ส่งคืนวัตถุ Personalbar ซึ่งสามารถสลับการมองเห็นได้ในหน้าต่าง
Window.screen
(en-US) Read only- ส่งคืนการอ้างอิงไปยังออบเจ็กต์หน้าจอที่เกี่ยวข้องกับหน้าต่าง
Window.screenX
(en-US) และWindow.screenLeft
(en-US) Read only- คุณสมบัติทั้งสองจะคืนระยะทางแนวนอนจากขอบด้านซ้ายของวิวพอร์ตของเบราว์เซอร์ของผู้ใช้ไปทางด้านซ้ายของหน้าจอ
Window.screenY
(en-US) และWindow.screenTop
(en-US) Read only- คุณสมบัติทั้งสองจะคืนระยะทางแนวตั้งจากเส้นขอบด้านบนของวิวพอร์ตเบราว์เซอร์ของผู้ใช้ไปที่ด้านบนของหน้าจอ
Window.scrollbars
(en-US) Read only- ส่งคืนอ็อบเจ็กต์แถบเลื่อนซึ่งสามารถสลับการมองเห็นได้ในหน้าต่าง
Window.scrollMaxX
(en-US) Read only- ค่าชดเชยสูงสุดที่สามารถเลื่อนหน้าต่างไปเป็นแนวนอนได้นั่นคือความกว้างของเอกสารลบด้วยความกว้างของวิวพอร์ต
Window.scrollMaxY
(en-US) Read only- ค่าชดเชยสูงสุดที่สามารถเลื่อนหน้าต่างไปยังแนวตั้งได้ (เช่นความสูงของเอกสารลบด้วยความสูงของวิวพอร์ต)
Window.scrollX
(en-US) Read only- ส่งคืนจำนวนพิกเซลที่เอกสารถูกเลื่อนไปแล้วในแนวนอน
Window.scrollY
(en-US) Read only- ส่งคืนจำนวนพิกเซลที่เอกสารถูกเลื่อนในแนวตั้งแล้ว
Window.self
(en-US) Read only- ส่งคืนการอ้างอิงอ็อบเจ็กต์ไปยังอ็อบเจ็กต์หน้าต่างเอง
Window.sessionStorage
(en-US)- ส่งคืนการอ้างอิงไปยังออบเจ็กต์หน่วยเก็บข้อมูลเซสชันที่ใช้ในการจัดเก็บข้อมูลที่สามารถเข้าถึงได้โดยต้นทางที่สร้าง
Window.sidebar
(en-US) Read only- ส่งคืนการอ้างอิงไปยังวัตถุหน้าต่างของแถบด้านข้าง
Window.speechSynthesis
(en-US) Read only- ส่งคืนออบเจ็กต์
SpeechSynthesis
(en-US) ซึ่งเป็นจุดเริ่มต้นในการใช้ฟังก์ชันการสังเคราะห์เสียงพูด Web Speech API Window.status
(en-US)- รับ / ตั้งค่าข้อความในแถบสถานะที่ด้านล่างของเบราว์เซอร์
Window.statusbar
(en-US) Read only- ส่งคืนออบเจ็กต์แถบสถานะซึ่งสามารถสลับการเปิดเผยได้ในหน้าต่าง
Window.toolbar
(en-US) Read only- ส่งคืนอ็อบเจ็กต์แถบเครื่องมือซึ่งสามารถสลับการเปิดเผยได้ในหน้าต่าง
Window.top
(en-US) Read only- ส่งคืนการอ้างอิงไปยังหน้าต่างที่อยู่บนสุดในลำดับชั้นของหน้าต่าง คุณสมบัตินี้เป็นแบบอ่านอย่างเดียว
Window.visualViewport
(en-US) Read only {{trial_inline}}- ส่งคืนออบเจ็กต์
VisualViewport
(en-US) ซึ่งแสดงถึงวิวพอร์ตภาพสำหรับหน้าต่างที่กำหนด Window.window
(en-US) Read only- ส่งคืนการอ้างอิงไปยังหน้าต่างปัจจุบัน
window[0]
,window[1]
ฯลฯ- ส่งคืนการอ้างอิงไปยัง
window
วัตถุในเฟรม ดูรายละเอียดเพิ่มเติมที่Window.frames
(en-US)
คุณสมบัติดำเนินการจากที่อื่น
WindowOrWorkerGlobalScope.caches
(en-US) Read only- ส่งคืนอ็อบเจ็กต์
CacheStorage
ที่เชื่อมโยงกับบริบทปัจจุบัน อ็อบเจ็กต์นี้เปิดใช้งานฟังก์ชันต่างๆเช่นการจัดเก็บเนื้อหาสำหรับการใช้งานออฟไลน์และสร้างการตอบสนองที่กำหนดเองสำหรับคำขอ WindowOrWorkerGlobalScope.indexedDB
(en-US) Read only- จัดเตรียมกลไกสำหรับแอปพลิเคชันเพื่อเข้าถึงความสามารถของฐานข้อมูลที่ทำดัชนีแบบอะซิงโครนัส ส่งคืนอ็อบเจ็กต์
IDBFactory
(en-US) WindowOrWorkerGlobalScope.isSecureContext
(en-US) Read only- ส่งคืนบูลีนที่ระบุว่าบริบทปัจจุบันปลอดภัย (
true
) หรือไม่ (false
) WindowOrWorkerGlobalScope.origin
(en-US) Read only- ส่งคืนจุดเริ่มต้นของวัตถุส่วนกลางโดยจัดลำดับเป็นสตริง (สิ่งนี้ยังไม่ปรากฏในเบราว์เซอร์ใด ๆ )
คุณสมบัติที่ไม่รองรับ
Window.content
(en-US) และWindow._content
Read only- ส่งคืนการอ้างอิงถึงองค์ประกอบเนื้อหาในหน้าต่างปัจจุบัน ตั้งแต่ Firefox 57 (เริ่มต้นใช้งานเฉพาะคืนเท่านั้น) ทั้งสองเวอร์ชันมีให้ใช้งานจากรหัสโครเมี่ยม (สิทธิพิเศษ) เท่านั้นและไม่สามารถใช้งานบนเว็บได้อีกต่อไป
Window.defaultStatus
(en-US)- รับ / ตั้งค่าข้อความแถบสถานะสำหรับหน้าต่างที่กำหนด
Window.dialogArguments
(en-US) Read only- รับอาร์กิวเมนต์ที่ส่งผ่านไปยังหน้าต่าง (หากเป็นกล่องโต้ตอบ) เมื่อมีการเรียก
window.showModalDialog ()
นี่คือnsIArray
Window.directories
(en-US)- คำพ้องความหมายของ
window.personalbar
(en-US) Window.globalStorage
- อ็อบเจ็กต์หน่วยเก็บข้อมูลจำนวนมากที่ใช้สำหรับจัดเก็บข้อมูลในหลายเพจ
Window.mozAnimationStartTime
(en-US)- เวลาในหน่วยมิลลิวินาทีนับตั้งแต่ยุคที่วงจรการเคลื่อนไหวปัจจุบันเริ่มต้นขึ้น ใช้
Animation.startTime
(en-US) แทน Window.mozPaintCount
(en-US)- ส่งคืนจำนวนครั้งที่เอกสารปัจจุบันถูกแสดงบนหน้าจอในหน้าต่างนี้ สามารถใช้เพื่อคำนวณประสิทธิภาพการแสดงผล
Window.orientation
(en-US) Read only- ส่งคืนการวางแนวเป็นองศา (เพิ่มขึ้นทีละ 90 องศา) ของวิวพอร์ตที่สัมพันธ์กับการวางแนวตามธรรมชาติของอุปกรณ์
Window.pkcs11
(en-US)- เดิมให้การเข้าถึงเพื่อติดตั้งและลบโมดูล PKCS11
Window.returnValue
- ค่าส่งคืนที่จะส่งกลับไปยังฟังก์ชันที่เรียกว่า
window.showModalDialog ()
เพื่อแสดงหน้าต่างเป็นกล่องโต้ตอบโมดอล
วิธีการ
อินเทอร์เฟซนี้สืบทอดเมธอดจากอินเทอร์เฟซ EventTarget
(en-US) และใช้เมธอดจาก WindowOrWorkerGlobalScope
(en-US) และ EventTarget
(en-US)
Window.alert ()
- แสดงกล่องโต้ตอบการแจ้งเตือน
Window.blur ()
- ตั้งโฟกัสให้ห่างจากหน้าต่าง
Window.cancelAnimationFrame ()
{{trial_inline}}- ช่วยให้คุณสามารถยกเลิกการโทรกลับที่กำหนดไว้ก่อนหน้านี้ด้วย
Window.requestAnimationFrame
(en-US) Window.cancelIdleCallback()
(en-US)- Enables you to cancel a callback previously scheduled with
Window.requestIdleCallback
(en-US). Window.clearImmediate()
(en-US)- Cancels the repeated execution set using
setImmediate
. Window.close()
(en-US)- Closes the current window.
Window.confirm()
(en-US)- Displays a dialog with a message that the user needs to respond to.
Window.dump()
(en-US)- Writes a message to the console.
Window.find()
(en-US)- Searches for a given string in a window.
Window.focus()
(en-US)- Sets focus on the current window.
Window.getComputedStyle()
(en-US)- Gets computed style for the specified element. Computed style indicates the computed values of all CSS properties of the element.
Window.getDefaultComputedStyle()
(en-US)- Gets default computed style for the specified element, ignoring author stylesheets.
Window.getSelection()
(en-US)- Returns the selection object representing the selected item(s).
Window.matchMedia()
(en-US)- Returns a
MediaQueryList
(en-US) object representing the specified media query string. Window.maximize()
- FIXME: NeedsContents
Window.minimize()
(en-US) (top-level XUL windows only)- Minimizes the window.
Window.moveBy()
(en-US)- Moves the current window by a specified amount.
Window.moveTo()
(en-US)- Moves the window to the specified coordinates.
Window.open()
(en-US)- Opens a new window.
Window.postMessage()
(en-US)- Provides a secure means for one window to send a string of data to another window, which need not be within the same domain as the first.
Window.print()
(en-US)- Opens the Print Dialog to print the current document.
Window.prompt()
(en-US)- Returns the text entered by the user in a prompt dialog.
Window.requestAnimationFrame()
(en-US)- Tells the browser that an animation is in progress, requesting that the browser schedule a repaint of the window for the next animation frame.
Window.requestIdleCallback()
(en-US)- Enables the scheduling of tasks during a browser's idle periods.
Window.resizeBy()
(en-US)- Resizes the current window by a certain amount.
Window.resizeTo()
(en-US)- Dynamically resizes window.
Window.scroll()
(en-US)- Scrolls the window to a particular place in the document.
Window.scrollBy()
(en-US)- Scrolls the document in the window by the given amount.
Window.scrollByLines()
(en-US)- Scrolls the document by the given number of lines.
Window.scrollByPages()
(en-US)- Scrolls the current document by the specified number of pages.
Window.scrollTo()
(en-US)- Scrolls to a particular set of coordinates in the document.
Window.setImmediate()
(en-US)- Executes a function after the browser has finished other heavy tasks
Window.setResizable()
- Toggles a user's ability to resize a window.
Window.sizeToContent()
(en-US)- Sizes the window according to its content.
Window.stop()
(en-US)- This method stops window loading.
Window.updateCommands()
(en-US)- Updates the state of commands of the current chrome window (UI).
Methods implemented from elsewhere
EventTarget.addEventListener()
(en-US)- Register an event handler to a specific event type on the window.
EventTarget.dispatchEvent()
(en-US)- Used to trigger an event.
WindowOrWorkerGlobalScope.atob()
(en-US)- Decodes a string of data which has been encoded using base-64 encoding.
WindowOrWorkerGlobalScope.btoa()
(en-US)- Creates a base-64 encoded ASCII string from a string of binary data.
WindowOrWorkerGlobalScope.clearInterval()
(en-US)- Cancels the repeated execution set using
WindowOrWorkerGlobalScope.setInterval()
(en-US). WindowOrWorkerGlobalScope.clearTimeout()
(en-US)- Cancels the delayed execution set using
WindowOrWorkerGlobalScope.setTimeout()
(en-US). WindowOrWorkerGlobalScope.createImageBitmap()
(en-US)- Accepts a variety of different image sources, and returns a
Promise
(en-US) which resolves to anImageBitmap
(en-US). Optionally the source is cropped to the rectangle of pixels originating at (sx, sy) with width sw, and height sh. WindowOrWorkerGlobalScope.fetch()
(en-US)- Starts the process of fetching a resource from the network.
EventTarget.removeEventListener
(en-US)- Removes an event listener from the window.
WindowOrWorkerGlobalScope.setInterval()
(en-US)- Schedules a function to execute every time a given number of milliseconds elapses.
WindowOrWorkerGlobalScope.setTimeout()
(en-US)- Schedules a function to execute in a given amount of time.
Deprecated methods
Window.back()
(en-US)- Moves back one in the window history. This method is deprecated; you should instead use
window.history.back()
(en-US). Window.captureEvents()
(en-US)- Registers the window to capture all events of the specified type.
Window.forward()
(en-US)- Moves the window one document forward in the history. This method is deprecated; you should instead use
window.history.forward()
(en-US). Window.getAttention()
- Flashes the application icon.
Window.home()
(en-US)- Returns the browser to the home page.
Window.openDialog()
(en-US)- Opens a new dialog window.
Window.releaseEvents()
(en-US)- Releases the window from trapping events of a specific type.
Window.showModalDialog()
(en-US)- Displays a modal dialog.
Event handlers
These are properties of the window object that can be set to establish event handlers for the various things that can happen in the window that might be of interest.
This interface inherits event handlers from the EventTarget
(en-US) interface and implements event handlers from WindowEventHandlers
(en-US).
Window.onappinstalled
(en-US)- Called when the page is installed as a webapp. See
appinstalled
(en-US) event. Window.onbeforeinstallprompt
(en-US)- An event handler property dispatched before a user is prompted to save a web site to a home screen on mobile.
Window.ondevicelight
(en-US)- An event handler property for any ambient light levels changes
Window.ondevicemotion
(en-US)- Called if accelerometer detects a change (For mobile devices)
Window.ondeviceorientation
(en-US)- Called when the orientation is changed (For mobile devices)
Window.ondeviceorientationabsolute
(en-US)- An event handler property for any device orientation changes.
Window.ondeviceproximity
(en-US)- An event handler property for device proximity event
Window.ongamepadconnected
(en-US)- Represents an event handler that will run when a gamepad is connected (when the
gamepadconnected (en-US)
event fires). Window.ongamepaddisconnected
(en-US)- Represents an event handler that will run when a gamepad is disconnected (when the
gamepaddisconnected (en-US)
event fires). Window.onmozbeforepaint
(en-US)- An event handler property for the
MozBeforePaint
event, which is sent before repainting the window if the event has been requested by a call to theWindow.mozRequestAnimationFrame()
(en-US) method. Window.onpaint
(en-US)- An event handler property for paint events on the window.
Window.onrejectionhandled
(en-US)- An event handler for handled
Promise
rejection events. Window.onuserproximity
(en-US)- An event handler property for user proximity events.
Window.onvrdisplayconnect
(en-US)- Represents an event handler that will run when a compatible VR device has been connected to the computer (when the
vrdisplayconnected
event fires). Window.onvrdisplaydisconnect
(en-US)- Represents an event handler that will run when a compatible VR device has been disconnected from the computer (when the
vrdisplaydisconnected
event fires). Window.onvrdisplayactivate
(en-US)- Represents an event handler that will run when a display is able to be presented to (when the
vrdisplayactivate
event fires), for example if an HMD has been moved to bring it out of standby, or woken up by being put on. Window.onvrdisplaydeactivate
(en-US)- Represents an event handler that will run when a display can no longer be presented to (when the
vrdisplaydeactivate
event fires), for example if an HMD has gone into standby or sleep mode due to a period of inactivity. Window.onvrdisplayblur
(en-US)- Represents an event handler that will run when presentation to a display has been paused for some reason by the browser, OS, or VR hardware (when the
vrdisplayblur
event fires) — for example, while the user is interacting with a system menu or browser, to prevent tracking or loss of experience. Window.onvrdisplayfocus
(en-US)- Represents an event handler that will run when presentation to a display has resumed after being blurred (when the
vrdisplayfocus
event fires). Window.onvrdisplaypresentchange
(en-US)- represents an event handler that will run when the presenting state of a VR device changes — i.e. goes from presenting to not presenting, or vice versa (when the
vrdisplaypresentchange
event fires).
Event handlers implemented from elsewhere
GlobalEventHandlers.onabort
(en-US)- Called when the loading of a resource has been aborted, such as by a user canceling the load while it is still in progress
WindowEventHandlers.onafterprint
(en-US)- Called when the print dialog box is closed. See
afterprint (en-US)
event. WindowEventHandlers.onbeforeprint
(en-US)- Called when the print dialog box is opened. See
beforeprint (en-US)
event. WindowEventHandlers.onbeforeunload
(en-US)- An event handler property for before-unload events on the window.
GlobalEventHandlers.onblur
(en-US)- Called after the window loses focus, such as due to a popup.
GlobalEventHandlers.onchange
(en-US)- An event handler property for change events on the window.
GlobalEventHandlers.onclick
(en-US)- Called after the ANY mouse button is pressed & released
GlobalEventHandlers.ondblclick
(en-US)- Called when a double click is made with ANY mouse button.
GlobalEventHandlers.onclose
(en-US)- Called after the window is closed
GlobalEventHandlers.oncontextmenu
(en-US)- Called when the RIGHT mouse button is pressed
GlobalEventHandlers.onerror
(en-US)- Called when a resource fails to load OR when an error occurs at runtime. See
error (en-US)
event. GlobalEventHandlers.onfocus
(en-US)- Called after the window receives or regains focus. See
focus (en-US)
events. WindowEventHandlers.onhashchange
(en-US)- An event handler property for
hashchange (en-US)
events on the window; called when the part of the URL after the hash mark ("#") changes. GlobalEventHandlers.oninput
(en-US)- Called when the value of an <input> element changes
GlobalEventHandlers.onkeydown
(en-US)- Called when you begin pressing ANY key. See
keydown (en-US)
event. GlobalEventHandlers.onkeypress
(en-US)- Called when a key (except Shift, Fn, and CapsLock) is in pressed position. See
keypress (en-US)
event. GlobalEventHandlers.onkeyup
(en-US)- Called when you finish releasing ANY key. See
keyup (en-US)
event. WindowEventHandlers.onlanguagechange
(en-US)- An event handler property for
languagechange (en-US)
events on the window. GlobalEventHandlers.onload
(en-US)- Called after all resources and the DOM are fully loaded. WILL NOT get called when the page is loaded from cache, such as with back button.
WindowEventHandlers.onmessage
(en-US)- Is an
EventHandler
(en-US) representing the code to be called when themessage
event is raised. GlobalEventHandlers.onmousedown
(en-US)- Called when ANY mouse button is pressed.
GlobalEventHandlers.onmousemove
(en-US)- Called continously when the mouse is moved inside the window.
GlobalEventHandlers.onmouseout
(en-US)- Called when the pointer leaves the window.
GlobalEventHandlers.onmouseover
(en-US)- Called when the pointer enters the window
GlobalEventHandlers.onmouseup
(en-US)- Called when ANY mouse button is released
WindowEventHandlers.onoffline
- Called when network connection is lost. See
offline (en-US)
event. WindowEventHandlers.ononline
- Called when network connection is established. See
online (en-US)
event. WindowEventHandlers.onpagehide
- Called when the user navigates away from the page, before the onunload event. See
pagehide (en-US)
event. WindowEventHandlers.onpageshow
- Called after all resources and the DOM are fully loaded. See
pageshow (en-US)
event. WindowEventHandlers.onpopstate
(en-US)- Called when a back button is pressed.
GlobalEventHandlers.onreset
(en-US)- Called when a form is reset
GlobalEventHandlers.onresize
(en-US)- Called continuously as you are resizing the window.
GlobalEventHandlers.onscroll
(en-US)- Called when the scroll bar is moved via ANY means. If the resource fully fits in the window, then this event cannot be invoked
GlobalEventHandlers.onwheel
(en-US)- Called when the mouse wheel is rotated around any axis
GlobalEventHandlers.onselect
(en-US)- Called after text in an input field is selected
GlobalEventHandlers.onselectionchange
(en-US)- Is an
EventHandler
(en-US) representing the code to be called when theselectionchange
event is raised. WindowEventHandlers.onstorage
(en-US)- Called when there is a change in session storage or local storage. See
storage (en-US)
event GlobalEventHandlers.onsubmit
(en-US)- Called when a form is submitted
WindowEventHandlers.onunhandledrejection
(en-US)- An event handler for unhandled
Promise
rejection events. WindowEventHandlers.onunload
(en-US)- Called when the user navigates away from the page.
Events
Listen to these events using addEventListener()
or by assigning an event listener to the oneventname
property of this interface.
error
(en-US)- Fired when a resource failed to load, or can't be used. For example, if a script has an execution error or an image can't be found or is invalid.
Also available via theonerror
(en-US) property. languagechange
(en-US)- Fired at the global scope object when the user's preferred language changes.
Also available via theonlanguagechange
(en-US) property. orientationchange
(en-US)- Fired when the orientation of the device has changed.
Also available via theonorientationchange
property. devicemotion
(en-US)- Fired at a regular interval, indicating the amount of physical force of acceleration the device is receiving and the rate of rotation, if available.
deviceorientation
(en-US)- Fired when fresh data is available from the magnetometer orientation sensor about the current orientation of the device as compared to the Earth coordinate frame.
resize
(en-US)- Fired when the window has been resized.
Also available via theonresize
(en-US) property. storage
(en-US)- Fired when a storage area (
localStorage
orsessionStorage
) has been modified in the context of another document.
Also available via theonstorage
(en-US) property.
Animation events
animationcancel
(en-US)- Fired when an animation unexpectedly aborts.
Also available via theonanimationcancel
(en-US) property. animationend
(en-US)- Fired when an animation has completed normally.
Also available via theonanimationend
(en-US) property. animationiteration
(en-US)- Fired when an animation iteration has completed.
Also available via theonanimationiteration
(en-US) property. animationstart
(en-US)- Fired when an animation starts.
Also available via theonanimationstart
(en-US) property.
Clipboard events
clipboardchange
- Fired when the system clipboard content changes.
copy
(en-US)- Fired when the user initiates a copy action through the browser's user interface.
Also available via theoncopy
(en-US) property. cut
(en-US)- Fired when the user initiates a cut action through the browser's user interface.
Also available via theoncut
(en-US) property. paste
(en-US)- Fired when the user initiates a paste action through the browser's user interface.
Also available via theonpaste
(en-US) property.
Connection events
offline
(en-US)- Fired when the browser has lost access to the network and the value of
navigator.onLine
has switched tofalse
.
Also available via theonoffline
property. online
(en-US)- Fired when the browser has gained access to the network and the value of
navigator.onLine
has switched totrue
.
Also available via theononline
property.
Focus events
blur
(en-US)- Fired when an element has lost focus.
Also available via theonblur
(en-US) property. focus
(en-US)- Fired when an element has gained focus.
Also available via theonfocus
(en-US) property
Gamepad events
gamepadconnected
(en-US)- Fired when the browser detects that a gamepad has been connected or the first time a button/axis of the gamepad is used.
Also available via theongamepadconnected
(en-US) property. gamepaddisconnected
(en-US)- Fired when the browser detects that a gamepad has been disconnected.
Also available via theongamepaddisconnected
(en-US) property
History events
hashchange
(en-US)- Fired when the fragment identifier of the URL has changed (the part of the URL beginning with and following the
#
symbol).
Also available via theonhashchange
(en-US) property. pagehide
(en-US)- Sent when the browser hides the current document while in the process of switching to displaying in its place a different document from the session's history. This happens, for example, when the user clicks the Back button or when they click the Forward button to move ahead in session history.
Also available through theonpagehide
event handler property. pageshow
(en-US)- Sent when the browser makes the document visible due to navigation tasks, including not only when the page is first loaded, but also situations such as the user navigating back to the page after having navigated to another within the same tab.
Also available using theonpageshow
event handler property. popstate
(en-US)- Fired when the active history entry changes.
Also available using theonpopstate
(en-US) event handler property.
Load & unload events
beforeunload
(en-US)- Fired when the window, the document and its resources are about to be unloaded.
Also available via theonbeforeunload
(en-US) property. DOMContentLoaded
(en-US)- Fired when the document has been completely loaded and parsed, without waiting for stylesheets, images, and subframes to finish loading.
load
(en-US)- Fired when the whole page has loaded, including all dependent resources such as stylesheets images.
Also available via theonload
(en-US) property. unload
(en-US)- Fired when the document or a child resource is being unloaded.
Also available via theonunload
(en-US) property.
Manifest events
appinstalled
(en-US)- Fired when the browser has successfully installed a page as an application.
Also available via theonappinstalled
(en-US) property. beforeinstallprompt
- Fired when a user is about to be prompted to install a web application.
Also available via theonbeforeinstallprompt
(en-US) property.
Messaging events
message
(en-US)- Fired when the window receives a message, for example from a call to
Window.postMessage()
(en-US) from another browsing context.
Also available via theonmessage
(en-US) property. messageerror
(en-US)- Fired when a
Window
object receives a message that can't be deserialized.
Also available via theonmessageerror
(en-US) property.
Print events
afterprint
(en-US)- Fired after the associated document has started printing or the print preview has been closed.
Also available via theonafterprint
(en-US) property. beforeprint
(en-US)- Fired when the associated document is about to be printed or previewed for printing.
Also available via theonbeforeprint
(en-US) property.
Promise rejection events
rejectionhandled
(en-US)- Sent every time a JavaScript
Promise
is rejected, regardless of whether or not there is a handler in place to catch the rejection.
Also available through theonrejectionhandled
(en-US) event handler property. unhandledrejection
(en-US)- Sent when a JavaScript
Promise
is rejected but there is no handler in place to catch the rejection.
Also available using theonunhandledrejection
(en-US) event handler property.
Transition events
transitioncancel
(en-US)- Fired when a CSS transition is canceled.
Also available via theontransitioncancel
(en-US) property. transitionend
(en-US)- Fired when a CSS transition has completed.
Also available via theontransitionend
(en-US) property. transitionrun
(en-US)- Fired when a CSS transition is first created.
Also available via theontransitionrun
property. transitionstart
(en-US)- Fired when a CSS transition has actually started.
Also available via theontransitionstart
property.
WebVR events
vrdisplayactivate
(en-US)- Fired when a VR display becomes available to be presented to, for example if an HMD has been moved to bring it out of standby, or woken up by being put on.
Also available via theonvrdisplayactivate
(en-US) property. vrdisplayblur
(en-US)- Fired when presentation to a VR display has been paused for some reason by the browser, OS, or VR hardware.
Also available via theonvrdisplayblur
(en-US) property. vrdisplayconnect
(en-US)- Fired when a compatible VR display is connected to the computer.
Also available via theonvrdisplayconnect
(en-US) property. vrdisplaydeactivate
(en-US)- Fired when a VR display can no longer be presented to, for example if an HMD has gone into standby or sleep mode due to a period of inactivity.
Also available via theonvrdisplaydeactivate
(en-US) property. vrdisplaydisconnect
(en-US)- Fired when a compatible VR display is disconnected from the computer.
Also available via theonvrdisplaydisconnect
(en-US) property. vrdisplayfocus
(en-US)- Fired when presentation to a VR display has resumed after being blurred.
Also available via theonvrdisplayfocus
(en-US) property. vrdisplaypresentchange
(en-US)- Fired when the presenting state of a VR display changes — i.e. goes from presenting to not presenting, or vice versa.
Also available via theonvrdisplaypresentchange
(en-US) property. vrdisplaypointerrestricted
- ยิงเมื่อป้อนข้อมูลตัวชี้แสดงผล VR ของถูก จำกัด การบริโภคผ่านองค์ประกอบ pointerlocked
พร้อมใช้งานผ่านคุณสมบัติonvrdisplaypointerrestricted
vrdisplaypointerunrestricted
- ยิงเมื่อป้อนข้อมูลตัวชี้แสดงผล VR จะไม่ถูก จำกัด การบริโภคผ่านองค์ประกอบ pointerlocked
พร้อมใช้งานผ่านคุณสมบัติonvrdisplaypointerunrestricted
อินเทอร์เฟซ
ดูDOM อ้างอิง
ความเข้ากันได้ของเบราว์เซอร์
BCD tables only load in the browser