Change the URL in the browser without loading the new page using JavaScript

后端 未结 14 2223
忘掉有多难
忘掉有多难 2020-11-22 02:02

How would I have a JavaScript action that may have some effects on the current page but would also change the URL in the browser so if the user hits reload or bookmark, then

14条回答
  •  长情又很酷
    2020-11-22 02:39

    What is working for me is - history.replaceState() function which is as follows -

    history.replaceState(data,"Title of page"[,'url-of-the-page']);
    

    This will not reload page, you can make use of it with event of javascript

提交回复
热议问题