javascript create url with parameters 1

javascript create url with parameters

you can use backticks ``
// url params
const elemA = "Los Angelis";
const elemB = "London";
window.location.href = `http://www.gorissen.info/Pierre/maps/googleMapLocation.php?lat=${elemA}&lon=${elemB}&setLatLon=Set`;

Here is what the above code is Doing:
1. We’re creating two variables, elemA and elemB, and assigning them values.
2. We’re using the window.location.href property to set the current URL to the URL we want to go to.
3. We’re using the ${} syntax to insert the values of elemA and elemB into the URL.

Similar Posts