Reputation: 41
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
Then a POPUP window asking for input - "sweet"
Resulting URL
Upvotes: 4
Views: 4710
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
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