| reload() | ทำการ refresh หน้าจอ |
|---|---|
| replace() | ใช้เปลี่ยน page ไปยัง url ที่กำหนด และ back กลับไปไม่ได้ |
| assign() | ใช้เปลี่ยน page ไปยัง url ที่กำหนด และ back กลับไปได้ |
| pathname | ใช้คืนค่า path ตั้งแต่ root จนถึงไฟล์ที่หน้าต่างเรียกใช้ |
| href | ใช้กำหนดให้ page ไปยัง url ที่กำหนด หรือคืนค่า url |
| protocol | ใช้คืนค่า ประเภทของการติดต่อสื่อสารกับเครือข่ายอินเตอร์เน็ต |
| host | ใช้คืนค่า ชื่อ host ( หรือชื่อ domain นั่นเอง ) และหมายเลข port |
| hostname | ใช้คืนค่า ชื่อ host ( หรือชื่อ domain นั่นเอง ) |
| port | ใช้คืนค่า หมายเลข port |
| hash | ใช้คืนค่าชื่อของ anchor ( ที่ใช้เชื่อมโยงภายในหน้าเวปเดียวกัน ) |
| search | ใช้คืนค่า keyword ที่ส่งไปยัง url โดยเริ่มจากเครื่องหมาย "?" |
method:reload ();
return type:void
content:ทำการ refresh หน้าจอ
example:window.location.reload();
method:replace ( url );
return type:void
content:ใช้เปลี่ยน page ไปยัง url ที่กำหนด และ back กลับไปไม่ได้
example:window.location.replace ( "http://www.bamboolabcode.com" );
method:assign ( url );
return type:void
content:ใช้เปลี่ยน page ไปยัง url ที่กำหนด และ back กลับไปได้
example:window.location.assign ( "http://www.bamboolabcode.com" );
property:pathname;
return type:string
content:ใช้คืนค่า path ตั้งแต่ root จนถึงไฟล์ที่หน้าต่างเรียกใช้
example:alert ( window.location.pathname );
property:href;
return type:string, void
content:ใช้กำหนดให้ page ไปยัง url ที่กำหนด หรือคืนค่า url
example:window.location.href = "http://www.bamboolabcode.com";
comment:บางครั้งอาจมีการเข้ารหัส ascii ไว้ แต่ก็สามารถถอดรหัสได้ด้วยคำสั่ง unescape
property:protocol;
return type:string
content:ใช้คืนค่า ประเภทของการติดต่อสื่อสารกับเครือข่ายอินเตอร์เน็ต
example:alert ( window.location.protocol );
property:host;
return type:string
content:ใช้คืนค่า ชื่อ host ( หรือชื่อ domain นั่นเอง ) และหมายเลข port
example:alert ( window.location.host );
property:hostname;
return type:string
content:ใช้คืนค่า ชื่อ host ( หรือชื่อ domain นั่นเอง )
example:alert ( window.location.hostname );
property:port;
return type:number
content:ใช้คืนค่า หมายเลข port
example:alert ( window.location.port );
comment:ถ้าใช้ protocol เป็น http ส่วนมาก Port คือ 80 เสมอ
property:hash;
return type:string
content:ใช้คืนค่าชื่อของ anchor ( ที่ใช้เชื่อมโยงภายในหน้าเวปเดียวกัน )
example:alert ( window.location.hash );
property:search;
return type:string
content:ใช้คืนค่า keyword ที่ส่งไปยัง url โดยเริ่มจากเครื่องหมาย "?"
example:alert ( window.location.search );