changing page url without refreshing page

后端 未结 3 2013
耶瑟儿~
耶瑟儿~ 2021-01-01 07:35

Is this even possible?

Here\'s the problem:

I have a keyword search with this URL(after searching) : http://localhost/thi/search?keyword=key

Then I h

3条回答
  •  青春惊慌失措
    2021-01-01 08:31

    With HTML5 it's possible. Use window.history.pushState().

    Example :

    if(currentHref!=window.location){
        window.history.pushState({path:currentHref},'',currentHref);    
    }
    

    Details and explanations : http://tinywall.info/2012/02/22/change-browser-url-without-page-reload-refresh-with-ajax-request-using-javascript-html5-history-api-php-jquery-like-facebook-github-navigation-menu/

提交回复
热议问题