Bhavan Kumar Natarajan Bhavan Kumar Natarajan - 2 months ago 4
Javascript Question

Removing Query String from URL by using jquery (working with issue)

In my website blog pages added query string in that page URL. I wanted to remove the query string from the URL. So i used to go with jquery and i wrote and added into my scripts. It removes the query string but keep on refreshing the page upto nth time. I used to "one" jquery method. That also doesn't work.

Can you help me

My Script is

window.location.href = window.location.href.split('?')[0];


setting a value to window.location.href will reload the page. Try this:

    var url = window.location.href;
    var a = url.indexOf("?");
    var b =  url.substring(a);
    var c = url.replace(b,"");
    url = c;