“Zdobądź obecny adres URL JS” Kod odpowiedzi

Zdobądź obecny adres URL JS

var currentUrl = window.location.href;
Grepper

Zdobądź obecny JavaScript URL

window.location.pathname; // Returns path only (/path/example.html)
window.location.href;     // Returns full URL (https://example.com/path/example.html)
window.location.origin;   // Returns base URL (https://example.com)
Spyder

JavaScript Get Domena

window.location.hostname
Friendly Hawk

Zdobądź obecny adres URL z JavaScript?

console.log(window.location.href);

As noted in the comments, the line below works, but it is bugged for Firefox.
document.URL
Mr. Samy

JavaScript Uzyskaj bieżący adres URL

let location = window.location.href;
Undefined

Zdobądź obecny adres URL z JavaScript?

window.location.href
As noted in the comments, the line below works, but it is bugged for Firefox.

document.URL
shafeeque

Odpowiedzi podobne do “Zdobądź obecny adres URL JS”

Pytania podobne do “Zdobądź obecny adres URL JS”

Więcej pokrewnych odpowiedzi na “Zdobądź obecny adres URL JS” w JavaScript

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu