Using Parameters in the URL
Last updated
Last updated
As well as passing the configuration options via the constructor of the WBBPlugin object, you can also pass the parameters in the page URL.
For example, if you want to have the widget load on a specific page called test.html
then by adding the following code to you JavaScript you could load the page test.html?primaryColour=#443388
and see the primary colour of the widget change.
The code above would be added inside the addEventListener
part of your code, as mentioned in the guide.
In this example, line 10
either looks for the parameter primaryColour
via the query parameters on the URL, or if it is not found, falls back to using the default value of 007FAD
. You can use this same approach for any parameters you wish to be able to specify on the URL.
By only using the getQueryParam
function on the parameters you want users to be able to change, you ensure that the system can't be used in ways you don't intend.