Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

get last path segment of url in javascript

const last_segment = window.location.pathname.split('/').pop();
Comment

javascript get last url segment

console.log(this.href.substring(this.href.lastIndexOf('/') + 1));
Comment

PREVIOUS NEXT
Code Example
Javascript :: regex date yyyy-mm-dd 
Javascript :: discord bot playing game 
Javascript :: nodejs current timestamp unix 
Javascript :: window is not defined Next Js 
Javascript :: react toastify dark mode 
Javascript :: gcloud storage cors 
Javascript :: jquery summernote set value 
Javascript :: assign this value or if it is undefined this other value javascript 
Javascript :: unique string id js 
Javascript :: jsconfig.json 
Javascript :: onchange not working input jquery 
Javascript :: add item to list javascript 
Javascript :: compose javascript 
Javascript :: multiple value selected in select2 
Javascript :: Array.include is not a function javascript error help 
Javascript :: javascript onclick open url same window 
Javascript :: react dictionary key value avec 2 variable 
Javascript :: javascript join 
Javascript :: performance.now() javascript 
Javascript :: javascript button 
Javascript :: react-router-dom 
Javascript :: timestamp to date javascript 
Javascript :: fs , valid path check 
Javascript :: bootstrap icons react 
Javascript :: node js variables in string 
Javascript :: js load js file 
Javascript :: get select2 selected value jquery 
Javascript :: js addeventlistener hover 
Javascript :: all javascript pattern programs 
Javascript :: get html input value by class name 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =