add( )


Adds query parameters to the current page's URL.

Adds one or more query parameters to the current page's URL.

The add() function can only be used when browser rendering happens, meaning you can only use it in frontend code after the page is ready.

If a specified key already exists as a query parameter, the newly specified value will overwrite the key's previous value.

Calling the add() function triggers the onChange() event handler if it has been registered.

Note: To retrieve the page's current query parameters, use the query property.

Method Declaration
Copy
function add(toAdd: object): void;
Method Parameters
toAddToAddRequired

An object containing a key

pair for each query parameter to add to the URL, where the object's keys are the query parameter keys and the object's values are the corresponding query parameter values.

JavaScript
import wixLocationFrontend from "wix-location-frontend"; // ... wixLocationFrontend.queryParams.add({ key2: "value2new", key3: "value3", }); // URL before addition: // www.mysite.com/page?key1=value1&key2=value2 // URL will look like: // www.mysite.com/page?key1=value1&key2=value2new&key3=value3
Did this help?

remove( )


Removes query parameters from the current page's URL.

Removes one or more query parameters to the current page's URL.

The remove() function can only be used when browser rendering happens, meaning you can only use it in frontend code after the page is ready.

If a specified key does not exist as a query parameter, it is ignored.

Calling the remove() function triggers the onChange() event handler if it has been registered.

Note: To retrieve the page's current query parameters, use the query property.

Method Declaration
Copy
function remove(toRemove: Array<string>): void;
Method Parameters
toRemoveArray<string>Required

List of keys to remove.

JavaScript
import wixLocationFrontend from "wix-location-frontend"; // ... wixLocationFrontend.queryParams.remove(["key1"]); // URL before removal: // www.mysite.com/page?key1=value1&key2=value2 // URL after removal: // www.mysite.com/page?key2=value2
Did this help?