jQuery remove query string parameter from url

jQuery remove query string parameter from url

A query string is the part of a URL that includes field-value pairs.

Here we are going to remove query string from URL using JavaScript.

There are number of benefits of clean URL.

Clean URL always looks better and prevent user to see if you are tracking where they came from.

It is helpful for security reasons.

Example 1 :
  1. $(document).ready(function(){
  2.     var uri = window.location.toString();
  3.     if (uri.indexOf("?") > 0) {
  4.      var clean_uri = uri.substring(0, uri.indexOf("?"));
  5.      window.history.replaceState({}, document.title, clean_uri);
  6.     }
  7. });
Example 2 :
  1. var clean_uri = location.protocol + "//" + location.host + location.pathname;
  2. window.history.replaceState({}, document.title, clean_uri);

Phone: (+91) 8800417876
Noida, 201301
Betwinner
pendik escort
kartal escort