MohdSaqib2003 / append_query_params_in_url

This app is about , how to add one or more query parameters in url.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Code

To add/update query params
const url = new URL(window.location.href);
url.searchParams.set(query, value);                 // ?page=4 (here query = "page" and value = 4);
window.history.pushState({ path: url.href }, '', url.href);

To get the value of query params
const url = new URL(window.location.href);
const query_value =  url.searchParams.get(query);                 // ?page=4 (here query_value = 4);

To delete query params
const url = new URL(window.location.href);
url.searchParams.delete(query);                 // ?page=4 (here page and its value will be deleted);
window.history.pushState({ path: url.href }, '', url.href);

About

This app is about , how to add one or more query parameters in url.


Languages

Language:JavaScript 97.6%Language:HTML 2.4%