jQuery remove query string parameter from url – onlinecode
In this post we will give you information about jQuery remove query string parameter from url – onlinecode. Hear we will give you detail about jQuery remove query string parameter from url – onlinecodeAnd how to use it also give you demo for it if it is necessary.
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 :
- $(document).ready(function(){
- var uri = window.location.toString();
- if(uri.indexOf("?")>){
- var clean_uri = uri.substring(, uri.indexOf("?"));
- window.history.replaceState({}, document.title, clean_uri);
- }
- });
$(document).ready(function(){ var uri = window.location.toString(); if (uri.indexOf("?") > 0) { var clean_uri = uri.substring(0, uri.indexOf("?")); window.history.replaceState({}, document.title, clean_uri); } });
Example 2 :
- var clean_uri = location.protocol +"//"+ location.host + location.pathname;
- window.history.replaceState({}, document.title, clean_uri);
var clean_uri = location.protocol + "//" + location.host + location.pathname; window.history.replaceState({}, document.title, clean_uri);
It remove the query string from URL without reloading page. It is helpful when your URL is long and your server gives the error 414 Request-URI Too Long HTTP status code then using this script you are able to remove all query string and make a short and fresh URL.
Hope this code and post will helped you for implement jQuery remove query string parameter from url – onlinecode. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs