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 :: get server side props 
Javascript :: javascript remove object from array 
Javascript :: uppercase first letter javascript 
Javascript :: react native prevent rotation of screen 
Javascript :: hex string to decimal string javascript 
Javascript :: check fpr multiple values in an array jquery 
Javascript :: vuejs alerts 
Javascript :: how to swap two elements in an array javascript 
Javascript :: navlink 
Javascript :: reset select2 jquery | clear select2 option value 
Javascript :: node sudo nvm 
Javascript :: javascript connect metamask 
Javascript :: cors error in node js express 
Javascript :: patterns in javascript 
Javascript :: change console log to print javascript 
Javascript :: ** javascript Exponentiation 
Javascript :: set cors for a react node application socket error 
Javascript :: price range slider bootstrap 4 
Javascript :: get input js 
Javascript :: set selected option jquery 
Javascript :: nodejs return code 
Javascript :: recieve voice channel audio discord.js 
Javascript :: react timer 
Javascript :: Download excel using reactJS 
Javascript :: working with json in javascript 
Javascript :: read json file into array javascript 
Javascript :: javascript static variable in class 
Javascript :: javascript select function 
Javascript :: javascript next friday 
Javascript :: foreach method javascript 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =