“Lokasi Jendela” Kode Jawaban

JavaScript mendapatkan URL saat ini

var currentUrl = window.location.href;
Grepper

window.href

//its actually 
window.location.href = "/App/Home"
//or
window.location.href = "https://www.google.com/"
Confused Penguin

window.location

window.location.href = link;
// or
window.location.assign(link);
Inquisitive Iguana

Lokasi Jendela

document.getElementById("demo").innerHTML = 
"The full URL of this page is:<br>" + window.location.href;
//Result
//The full URL of this page is: https://www.w3schools.com/js/tryit.asp?filename=tryjs_loc_href

document.getElementById("demo").innerHTML =
"Page hostname is " + window.location.hostname;
//Result
//Page hostname is www.w3schools.com

document.getElementById("demo").innerHTML =
"Page path is " + window.location.pathname;
//Result
//Page path is /js/js_window_location.asp
Shadow

Lokasi Jendela Javascript

document.getElementById("demo").innerHTML =
"Page location is " + window.location.href;
naly moslih

Jawaban yang mirip dengan “Lokasi Jendela”

Pertanyaan yang mirip dengan “Lokasi Jendela”

Lebih banyak jawaban terkait untuk “Lokasi Jendela” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya