Fungsi Javascript Terkait Nama Domain, Url, Hostname dan Port
Megetahui hash url
window.location.hash
output : #2
Mengetahui host
window.location.hostname
output : localhost
Mengambil host dan port
window.location.host
output : localhost:4200
Mengambil full url
window.location.href
output : http://localhost:4200/landing?query=1#2
Mengambil origin url
window.location.origin
output : http://localhost:4200
Mengambil port yang digunakan
window.location.port
output : 4200
Mengambil protocol yang digunakan
window.location.protocol
output : http:
Mengambil lokasi pencarian
window.location.search
output : ?query=1
Mengambil path name
window.location.pathname
output : /landing