Remove URL parameters without refreshing page

I am trying to remove everything after the “?” in the browser url on document ready.

Here is what I am trying:

jQuery(document).ready(function($) {

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

I can do this and see it the below works:

jQuery(document).ready(function($) {

var url = window.location.href;
    alert(url.split('?')[0]);
});

15 Answers
15

Leave a Comment