onlinecode

How to remove query string from URL using JQuery

How to remove query string from URL using JQuery

In this post we will give you information about How to remove query string from URL using JQuery. Hear we will give you detail about How to remove query string from URL using JQueryAnd how to use it also give you demo for it if it is necessary.

Why remove query strings?

Main two reasons for this.

1. Clear URL alwaya look better than the long URL

2. When you are not remove your query string from URL. then all get variable show in you URL string. sometime it not good for a security

You can remove your query string using this simple Jquery code.

$(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);

}

});

Hope this code and post will helped you for implement How to remove query string from URL using JQuery. 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

For More Info See :: laravel And github

Exit mobile version