0

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)
asked Jun 2, 2021 at 15:22
1

1 Answer 1

2

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();
answered Jun 2, 2021 at 16:22
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.