Content change via URL parameter

15 views Asked by At

I have a website where I want to provide people with specific coupon links. For example, this is the URL of my website:

abc.com/productID

I want to dynamically change the text on this page to something like this:

abc.com/productID?CodeCuponProd="Bla Bla"

Can this be done via the URL?

enter image description here

1

There are 1 answers

0
Mister Jojo On

you can do this with history.replaceState().

in your exemple it is :


let url = "https://example.com/productID";

history.replaceState(null, null, url + '?CodeCuponProd="Bla Bla"');