Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript absolute path

location.pathname //gives you the local part of the url.

var filename = location.pathname.match(/[^/]+$/)[0]
//The above gives you only the very last part. 
//For example, if you are on 
//http://somedomain/somefolder/filename.html, it will give you filename.html

//if you inspect the window.location object you will see

hash:       
host:       stackoverflow.com
hostname:   stackoverflow.com
href:       http://stackoverflow.com/questions/8401879/get-absolute-path-in-javascript
pathname:   /questions/8401879/get-absolute-path-in-javascript
port:       
protocol:   http:
search:     
Comment

PREVIOUS NEXT
Code Example
Javascript :: vue inline style bind 
Javascript :: how to print object in JavaScript, Object print in JavaScript 
Javascript :: get value of key in object mongodb 
Javascript :: calculus of finite differences calculator 
Javascript :: get hover element js 
Javascript :: mean vs mern stack 
Javascript :: javascript copy some properties from one object to another 
Javascript :: remove symbols from cpf js 
Javascript :: mongoose unique error message 
Javascript :: cors express tutorial 
Javascript :: swal change confirm button class 
Javascript :: how to print numbers from 1 to 100 in javascript 
Javascript :: js check string for isogram 
Javascript :: how to create a form without a submit button javascript 
Javascript :: converting javascript object to json 
Javascript :: how to install formik in react native 
Javascript :: js C:fakepath 
Javascript :: angular loop 
Javascript :: how to generate random number in javascript 
Javascript :: how to use Space for vertically in antd 
Javascript :: javascript date custom string format 
Javascript :: js get first letter of string 
Javascript :: quine 
Javascript :: jquery cdn in react 
Javascript :: flutter regular expression for arabic and english characters 
Javascript :: javascript stop the form from reloading 
Javascript :: javascript canvas reset transform 
Javascript :: iterate over map in javascript 
Javascript :: get all keys in json object 
Javascript :: react keydown event listener 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =