Olga
0
Q:

get url javascript

var currentUrl = window.location.href;
21

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

 
2
console.log(window.location.origin);
0
let url = 'https://www.example.com?name=n1&name=n2';
let params = (new URL(url)).searchParams;
params.get('name') // "n1"
params.getAll('name') // ["n1", "n2"]
1
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)
0

New to Communities?

Join the community