1

I have URL adresses like this:

http:://www.mywebsite.com/myapp?brand=nameOfBrand&user=0123456&type=comm

I have to use that info to show the logo of 'nameOfBrand'. So if I get brand=google, the logo of Google will appear, if I get brand=Amazon, the logo of Amazon appears, and so on...

Do you know how I can get this parameter?

1 Answer 1

2

var url_string = "http://www.mywebsite.com/myapp?brand=nameOfBrand&user=0123456&type=comm"; //window.location.href
var url = new URL(url_string);
var brand = url.searchParams.get("brand");
console.log(brand);

You can use URL to convert it and using searchParams.get method to grab the particular value that you want.

For more information

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.