Roshan
Roshan

Reputation: 41

How do I create a bookmark in chrome that gives a popup to append a URL?

I would like to create a bookmark in chrome that when clicked will display a popup window for text input. Take that input and append to a URL.

Example: The URL I would like to append

https://store.com/admin/tableviewer.asp?table=Discounts&IsASearch=Y&submit.search.x=search&CouponCode=

Then a POPUP window asking for input - "sweet"

Resulting URL

https://store.com/admin/tableviewer.asp?table=Discounts&IsASearch=Y&submit.search.x=search&CouponCode=sweet

Upvotes: 4

Views: 4710

Answers (2)

ba5eem
ba5eem

Reputation: 132

Check out this support article for how to do this: https://support.mozilla.org/en-US/questions/1200286

javascript:window.location = "https://mycompany" + prompt("enter string:");

Upvotes: 1

Eliya Cohen
Eliya Cohen

Reputation: 11478

Welcome to StackOverflow.

You can use the built-in window.prompt (or just prompt()) Function. It opens an alert with input and returns the value you put it. I assume you want to redirect to the desired link, so you redirect by setting window.location to your desired location.

Look at this demo:

const word = prompt("Please enter value", "sweet");
const url = 'https://store.com/admin/tableviewer.asp?table=Discounts&IsASearch=Y&submit.search.x=search&CouponCode=';

if (word) {
  window.location = url + word;
}

Upvotes: 0

Related Questions