Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

get current url js

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 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 :: how to pass the data from one page to another in javascript 
Javascript :: js pad array 
Javascript :: how to get the div value in jquery 
Javascript :: javascript fs read 
Javascript :: javascript get item in array by id 
Javascript :: ternaire js 
Javascript :: uselocation react 
Javascript :: how to change background color though props 
Javascript :: axios how to get error response 
Javascript :: get data attribute javascript 
Javascript :: next js start 
Javascript :: as it does not contain a package.json file. react 
Javascript :: timestamp convert moment vue 
Javascript :: convert string to unicode javascript 
Javascript :: node js get list of all names of object array 
Javascript :: jquery declare variable 
Javascript :: poo js 
Javascript :: play sound with keydown javascript 
Javascript :: difference between find and filter javascript 
Javascript :: render markdown in nextjs 
Javascript :: print random string from an array to screen in javascript 
Javascript :: print all days names of a month js javascript 
Javascript :: javascript get child element by parent id 
Javascript :: ajax submit form data 
Javascript :: nginx react router 
Javascript :: how to access dictionary keys in js 
Javascript :: get domain name with regex 
Javascript :: check upload img extension jquery 
Javascript :: js filter out doubles 
Javascript :: map of filtered data react 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =