how to remove query string from url?

Today, We want to share with you how to remove query string from url?.In this post we will show you remove specific parameter from url jquery, hear for how to remove query string from url after page load? we will give you demo and example for implement.In this post, we will learn about Get Query String Parameters from URL using JQuery with an example.

How to remove query string from URL using JQuery?

	var url = window.location.toString();
	if (url.indexOf("?") > 0) {
	    var getPathFromUrl = url.substring(0, url.indexOf("?"));
	    window.history.replaceState({}, document.title, getPathFromUrl);

Remove querystring from URL

Example 1:

function getPathFromUrl(url) {
  return url.split("?")[0];

Example 2:

var myWebsiteLiveURI = '/Members/Details?SortDirection=dsc&Sort=Age&Page=3&Page2=3';
var i;

// Testing the substring method
i = 0;
console.time('4cgnadhi substring');
while (i < 10000) {
    myWebsiteLiveURI.substring(0, myWebsiteLiveURI.indexOf('?'));
console.timeEnd('4cgnadhi substring');

// Testing the split method
i = 0;
console.time('4cgnadhi split');
while (i < 10000) {
console.timeEnd('4cgnadhi split');

// Testing the RegEx method
i = 0;
var re = new RegExp("[^?]+");
console.time('4cgnadhi regex');
while (i < 10000) {
console.timeEnd('4cgnadhi regex');

I hope you get an idea about Remove Query String with JavaScript and HTML5.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.