Reputation: 111
I have this link http://localhost:5000/index.html?cmluaWRhZDUxMbWFpbC5jb218YXlpYnFp how can i get this part cmluaWRhZDUxMbWFpbC5jb218YXlpYnFp only?
let location_url = window.location.pathname;
let new_url = '';
console.log("location_url.charAt( 0 ): ",location_url.charAt( 0 ))
console.log("location_url.slice( 1 ): ",location_url.slice( 1 ))
if( location_url.charAt( 0 ) === '/' )
new_url = location_url.slice( 1 );
console.log(new_url)
Upvotes: 0
Views: 508
Reputation: 36
You can do like this :
// Get your url string
var fullURL = window.location.href;
// Build an URL from the string
var URL = new URL(fullURL);
// Extract the data you are looking for
var result = URL.searchParams.toString();
Upvotes: 2