Remove URL parameters without refreshing page

前端 未结 13 996
执念已碎
执念已碎 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:23

    I belive the best and simplest method for this is:

    var newURL = location.href.split("?")[0];
    window.history.pushState('object', document.title, newURL);
    

提交回复
热议问题