How can I remove the query string from the url after the page loads?

前端 未结 10 1111
栀梦
栀梦 2020-12-16 10:03

I have a URL with a long query string attached to it. After the page loads, I do not require the query string. So I want to remove the query string from the address bar with

10条回答
  •  暖寄归人
    2020-12-16 10:43

    Updated Code Now it will work

    Just Add Below code in you page whose link you want to change.

    // javascript function
    
       function buildLin(first) {
        var firs = first.toString()
           //alert(firs);
           //document.getElementById("team").value = "1";
               document.location.hash = "#" + firs.replace(/ /g, "_");
            //alert(document.location.hash);
        }
    
     //jQuery to call above function after page loads
    
      $(document).ready(function () {
          buildLin(2);
      });
    

    Don't forget to add http://code.jquery.com/jquery-latest.js on your page ​

提交回复
热议问题