Skip to content

MohdSaqib2003/append_query_params_in_url

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published