ตำแหน่งหน้าต่าง
วัตถุตำแหน่งหน้าต่าง
ออบเจ็กต์ตำแหน่งมีข้อมูลเกี่ยวกับ URL ปัจจุบัน
วัตถุตำแหน่งเป็นคุณสมบัติของวัตถุหน้าต่าง
วัตถุตำแหน่งสามารถเข้าถึงได้ด้วย:
window.location
หรือเพียงแค่ location
ตัวอย่าง
let origin = window.location.origin;
let origin = location.origin;
คุณสมบัติของอ็อบเจ็กต์ตำแหน่ง
Property | Description |
---|---|
hash | Sets or returns the anchor part (#) of a URL |
host | Sets or returns the hostname and port number of a URL |
hostname | Sets or returns the hostname of a URL |
href | Sets or returns the entire URL |
origin | Returns the protocol, hostname and port number of a URL |
pathname | Sets or returns the path name of a URL |
port | Sets or returns the port number of a URL |
protocol | Sets or returns the protocol of a URL |
search | Sets or returns the querystring part of a URL |
ตำแหน่ง Object Methods
Method | Description |
---|---|
assign() | Loads a new document |
reload() | Reloads the current document |
replace() | Replaces the current document with a new one |