Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript get current url

var currentUrl = window.location.href;
Comment

get the current url javascript

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)
Comment

get current url javascript

alert(window.location.href);
alert(document.URL);
Comment

Get the current URL with JavaScript?

console.log(window.location.href);

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

how to get the url of a page in javascript

// this gives you just the URL without params
var currentUrlWithoutParams = window.location.href.split("?")[0];
Comment

javascript get current url

let location = window.location.href;
Comment

get current location url javascript

// get current location url javascript

var Your_Current_URL = window.location.href;
Comment

get url of website javascript

document.URL
> "http://example.com/page1.html"

document.location.href
> "http://example.com/page1.html"
Comment

get url in javaScript

location.protocol

location.hostname

location.pathname

location.hash

location.href
Comment

Get the current URL with JavaScript?

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

document.URL
Comment

PREVIOUS NEXT
Code Example
Javascript :: create element javascript with class 
Javascript :: button disabled angular 
Javascript :: array notation in javascript 
Javascript :: js check if object has property 
Javascript :: react native rename package name 
Javascript :: c# write to file in json 
Javascript :: jquery if else on click 
Javascript :: store array in local storage js 
Javascript :: curl accept json 
Javascript :: prisma studio 
Javascript :: show console chrome mac 
Javascript :: quotient js 
Javascript :: timer.tc elixir 
Javascript :: phone number formatter javascript grepper 
Javascript :: how to do regex email validation with domain 
Javascript :: javascript reload page one time 
Javascript :: enable network request in react native 
Javascript :: express session destroy 
Javascript :: js cookie 
Javascript :: angular generate component 
Javascript :: negative number error handling in javascript 
Javascript :: jquery clone 
Javascript :: object loop in javascript 
Javascript :: js alert yes no 
Javascript :: mongoose count documents 
Javascript :: detect when page scroll to div javascript no jquery 
Javascript :: es6 foreach 
Javascript :: set value input date javascript 
Javascript :: angular httpheaders example 
Javascript :: ng generate component in folder 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =