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

how to get browser url in javascript

function getURL() {
  alert("The URL of this page is: " + window.location.href);
}
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 :: Vue use props in style 
Javascript :: javascript to string big number 
Javascript :: javascript while 
Javascript :: reverse geocoding javascript map 
Javascript :: axios get status code 
Javascript :: angular serve 
Javascript :: daysinmonth javascript 
Javascript :: react native remove text from string 
Javascript :: loopback upsert 
Javascript :: window.scroll 
Javascript :: javascript insert item into array 
Javascript :: write to console using jQuery 
Javascript :: import all images from folder reactjs 
Javascript :: html add class 
Javascript :: month list javascript 
Javascript :: javascript async fetch file html 
Javascript :: add jwt token in header 
Javascript :: react native no android sdk found 
Javascript :: phone patter regex 
Javascript :: error while connecting mongodb MongoParseError: option usefindandmodify is not supported 
Javascript :: how to reset settimeout in javascript 
Javascript :: get random number node js 
Javascript :: node.js f string 
Javascript :: how to convert string into blob in javascript 
Javascript :: disable button click jquery 
Javascript :: send refresh token in axios interceptor 
Javascript :: convert string into bigNumber in ethers.js 
Javascript :: Checking Empty JS Object 
Javascript :: fetch javascript 
Javascript :: vue 3 computed getter setter 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =