History API: Javascript Pushstate, get previous URL

后端 未结 3 928
暗喜
暗喜 2020-12-19 12:14
$(window).bind(\'statechange\',function(){
     var State = History.getState(),
     url = State.url;
});

In the following function, url returns th

3条回答
  •  一向
    一向 (楼主)
    2020-12-19 12:47

    Try this:

    alert(document.referrer);
    

    Note:

    The value is an empty string if the user navigated to the page directly (not through a link, but, for example, via a bookmark). Since this property returns only a string, it does not give you DOM access to the referring page.

    See more here: https://developer.mozilla.org/en-US/docs/DOM/document.referrer?redirectlocale=en-US&redirectslug=document.referrer

提交回复
热议问题