How to get the previous URL in JavaScript?

后端 未结 7 874
野趣味
野趣味 2020-11-22 06:05

Is there any way to get the previous URL in JavaScript? Something like this:

alert(\"previous url is: \" + window.history.previous.href);

7条回答
  •  孤城傲影
    2020-11-22 06:12

    
    

    document.referrer serves your purpose, but it doesn't work for Internet Explorer versions earlier than IE9.

    It will work for other popular browsers, like Chrome, Mozilla, Opera, Safari etc.

提交回复
热议问题