Location Object

Location Object គឺ​ជា​វត្ថុ​មួយ​ទៀត​ស្ថិត​នៅ​ក្នុង​ BOM (Browser Object Model) ដែល​នៅ​ក្នុង​នោះ​មាន​សម្បត្តិ​មួយ​ចំនួន ដែល​អាច​ត្រូវ​យក​មកប្រើ​ទាក់ទង​នឹង​អាស័យដ្ឋាន​របស់​គេហទំព័រ​។ ពិនិត្យ​កម្មវិធី​ខាង​ក្រោម​នេះ៖
<!DOCTYPE html>
<html>
  <head>
    <link href='https://fonts.googleapis.com/css?family=Odor+Mean+Chey' rel='stylesheet'>
  </head>
  <body style="font:14px/1.5 'Odor Mean Chey'">
  	

​ចុច​នៅ​​ទី​នេះ​ ដើម្បី​ពិនិត្យ​មើល​អាស័យដ្ឋាន​គេហទំព័រ​ដែល​អ្នក​កំពុង​ចូល​មើល​។

<script> function myFunction() { var url = "

​អាស័យដ្ឋាន​គេហទំព័រ​ដែល​អ្នក​កំពុង​ចូល​មើល​គឺ: " + location.href + "

"; document.getElementById("demo").innerHTML = url; } </script> </body> </html>

​ចុច​នៅ​​ទី​នេះ​ ដើម្បី​ពិនិត្យ​មើល​អាស័យដ្ឋាន​គេហទំព័រ​ដែល​អ្នក​កំពុង​ចូល​មើល​។


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