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)
-
2Does this answer your question? How do I split a string, breaking at a particular character?imjared– imjared2021年06月02日 15:25:30 +00:00Commented Jun 2, 2021 at 15:25
1 Answer 1
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();
Sign up to request clarification or add additional context in comments.
Comments
lang-js