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 :: js remove last character from string 
Javascript :: javascript get all cookies 
Javascript :: jquery add contenteditable="true" 
Javascript :: javascript get file extension 
Javascript :: jquery check how many child elements 
Javascript :: how to console.log formData 
Javascript :: change color of strike through line of text in react native 
Javascript :: jquery datepicker no weekends 
Javascript :: regex check for numbers only js 
Javascript :: shadow elevation react native 
Javascript :: disable inputetext in react native 
Javascript :: This is probably not a problem with npm. There is likely additional logging output above. 
Javascript :: electronjs start with devtools enabled 
Javascript :: dino game 
Javascript :: jquery document load 
Javascript :: moment format datetime postgresql 
Javascript :: node get all files in folder 
Javascript :: settimeout in angular 
Javascript :: react native button round 
Javascript :: node-fetch post request example 
Javascript :: store data in localstorage javascript 
Javascript :: add 1 day to date js 
Javascript :: regex of date yyyy-mm-dd 
Javascript :: npm create-react-app 
Javascript :: react props.children proptype 
Javascript :: javascript get weekday name 
Javascript :: javascript to redirect to another page after 5 seconds 
Javascript :: how to get the year in javascript 
Javascript :: adding a button in javascript 
Javascript :: jquery check scroll direction 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =