If you think you don't need to show the URL parameters all the time but need to keep then by the time the page is loaded, this is the better way.
var strKey = "strName";
var flKeyFound = false;
var url = "";
var query = window.location.search.substring(1);
var vars = query.split('&');
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split('=');
if (decodeURIComponent(pair[0]) != strKey) {
url = url + decodeURIComponent(pair[0]) + "=" + decodeURIComponent(pair[1]) + "&";
}
}
url = window.location.href.split('?')[0] + "?" + url.substring(0, url.length - 1);
if (history.pushState) {
window.history.pushState({ path: url }, '', url);
}
Paste this peace of JavaScript code will remove the parameter ("strName") and it's value from the query string once the page is loaded.
Make sure you execute this code after the page load is finished.
strName is the key here. Change it to any name as needed.
Read more about History API on JavaScript here.
Happy coding...
Make sure you execute this code after the page load is finished.
strName is the key here. Change it to any name as needed.
Read more about History API on JavaScript here.
Happy coding...