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 :: javascript measure time function 
Javascript :: mongodb query to check empty array 
Javascript :: macos chrome disable web security 
Javascript :: remove spaces in a string js 
Javascript :: jquery on enter key pressed 
Javascript :: javascript clear canvas 
Javascript :: only numeric values are allow in input jquery 
Javascript :: While trying to resolve module `idb` from file 
Javascript :: javascript redirect laravel route 
Javascript :: javascript clear localstorage 
Javascript :: angular valuechanges get id 
Javascript :: javascript sleep for 1 second 
Javascript :: react native component at bottom center 
Javascript :: Remove style attribute from div with jquery 
Javascript :: How do I get the number of days between two dates in JavaScript 
Javascript :: jquery ajax basic authentication 
Javascript :: javascript check if undefined 
Javascript :: add leading zeros to number javascript 
Javascript :: jquery get the length of input text 
Javascript :: joi phone number validation 
Javascript :: reduce decimals to 4 digits javascript 
Javascript :: js date add 1 day 
Javascript :: E: Unable to locate package nodejs 
Javascript :: create new react project 
Javascript :: add url query in js 
Javascript :: textarea react native 
Javascript :: ng serve host 0.0.0.0 
Javascript :: Remove line breaks with JavaScript 
Javascript :: react native hide stack navigator title 
Javascript :: javascript find file extension from string 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =