Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

get current url js

var currentUrl = window.location.href;
Comment

get site url javascript

document.URL
> "http://example.com/page1.html"

document.location.href
> "http://example.com/page1.html"

document.location.pathname
> "/page1.html"

document.location.origin
> "http://example.com"
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 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 :: random color 
Javascript :: Converting google document to pdf using Scrips 
Javascript :: angular detect chromebook 
Javascript :: $.post javascript 
Javascript :: Connect to socket.io node.js command line 
Javascript :: javascript non-repeating randomize array 
Javascript :: Add an item to the beginning of an Array 
Javascript :: how to setup icomoon in react js 
Javascript :: React Native typescript start new project 
Javascript :: bootstrap searchable pagination table example jquery 
Javascript :: let var diferencia 
Javascript :: javaScript setMinutes() Method 
Javascript :: how to make a timer in javascript 
Javascript :: Get element by ID with only a partial string 
Javascript :: socket emit to specific room using nodejs socket.io 
Javascript :: use map to loop through an array 
Javascript :: javascript remove element from the dom 
Javascript :: json api 
Javascript :: iife in javascript 
Javascript :: what are json files for 
Javascript :: javascript como recorrer un array multidimensional 
Javascript :: angular img src binding 
Javascript :: load external javascript from console 
Javascript :: how to store object in session storage 
Javascript :: date now javascript 
Javascript :: Prevent default event behavior 
Javascript :: Get the url and parse or url.parse deprecated solved 
Javascript :: Find the index of an item in the Array 
Javascript :: funciones invocan a funciones javascript 
Javascript :: javascript find index 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =