Posted inTechnology / JavaScript / jQuery / php / Programming

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.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype