Remove URL parameters without refreshing page

前端 未结 13 966
执念已碎
执念已碎 2020-12-07 08:00

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


        
13条回答
  •  攒了一身酷
    2020-12-07 08:24

    To clear out all the parameters, without doing a page refresh, AND if you are using HTML5, then you can do this:

    history.pushState({}, '', 'index.html' ); //replace 'index.html' with whatever your page name is

    This will add an entry in the browser history. You could also consider replaceState if you don't wan't to add a new entry and just want to replace the old entry.

提交回复
热议问题