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 in javaScript

location.protocol

location.hostname

location.pathname

location.hash

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 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 :: Manifest 3 content security policy 
Javascript :: jquery click on parent but not child 
Javascript :: set padding jquery 
Javascript :: js change video src 
Javascript :: title case javascript 
Javascript :: scoll a div to bottom in angular 
Javascript :: react router how to go back 
Javascript :: selected option attribute jquery 
Javascript :: create a new input with type checkbox javascript 
Javascript :: jquery append text to div 
Javascript :: js sleep sync 
Javascript :: js form submit listener 
Javascript :: mui image 
Javascript :: readonly attribute in html by javascript 
Javascript :: nginx rewrite proxy_pass 
Javascript :: react eslint error missing in props validation 
Javascript :: mouse coordinates not match with canvas coordinate 
Javascript :: javascript set target blank 
Javascript :: jquery get checked checkbox values array 
Javascript :: delete cr eslint 
Javascript :: get array of all property in object array 
Javascript :: react after deployment givin nginx 404 
Javascript :: how to enable and disable href in javascript 
Javascript :: js appendchild wait for callback 
Javascript :: convert/replace space to dash/hyphen javascript 
Javascript :: open a new tab when clicking on a link react 
Javascript :: get device type javascript 
Javascript :: jquery uncheck checkbox 
Javascript :: onclick go to url 
Javascript :: ScrollController not attached to any scroll views 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =