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 :: select2 in modal not work 
Javascript :: javascript code to edit webpage 
Javascript :: how to get element by title js 
Javascript :: install expo cli mac os 
Javascript :: how to get clicked radio button value in jquery 
Javascript :: convert to objectid mongoose 
Javascript :: react native rotate 
Javascript :: javascript end of day 
Javascript :: javascript async delay 
Javascript :: javascript loop through class elements 
Javascript :: textinput disable react native 
Javascript :: loop through object jquery 
Javascript :: remove a class after 100 milliseconds jquery 
Javascript :: dinosaur game 
Javascript :: how to use another port in angular 
Javascript :: get random number with min and max 
Javascript :: listing dir by nodejs 
Javascript :: nest js install and create project 
Javascript :: installing jQuery in react js 
Javascript :: javascript remove leading zeros from string 
Javascript :: html5 store object in localstorage 
Javascript :: javascript selection sort 
Javascript :: regex yyyy-mm-dd 
Javascript :: how to install react in windows 
Javascript :: use application/x-www-form-urlencoded in javascript 
Javascript :: jquery set href of link 
Javascript :: jquery display block 
Javascript :: jquery stoppropagation 
Javascript :: trigger change select element jquery 
Javascript :: execute javascript function when page loads 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =