cookies - How to get previous page URL in javascript? - Stack Overflow

How can I design a function that will track the previous page a user has viewed. It will be should be d

How can I design a function that will track the previous page a user has viewed. It will be should be designed to be called on each page.

I will be using a cookies for sure and also they should expire at the end of the visit.

How to achieve that ? I am new to JavaScript :(

How can I design a function that will track the previous page a user has viewed. It will be should be designed to be called on each page.

I will be using a cookies for sure and also they should expire at the end of the visit.

How to achieve that ? I am new to JavaScript :(

Share Improve this question asked Jun 8, 2012 at 9:11 Anuj KulkarniAnuj Kulkarni 2,1997 gold badges33 silver badges45 bronze badges 4
  • Not possible unless it is on the same domain. document.referrer may hold the previous page but also may not. You can set a cookie, but the user may e from a different page in the same session. Can you explain what you need to do rather than how you think you may need to do it? – mplungjan Commented Jun 8, 2012 at 9:15
  • previous page of a particular website or last viewed page from his history??? – Sibu Commented Jun 8, 2012 at 9:21
  • 1 Yes previous page of a particular website ... – Anuj Kulkarni Commented Jun 8, 2012 at 9:35
  • 1 possible duplicate of How do you get the previous url in Javascript? – jwueller Commented Apr 6, 2013 at 14:34
Add a ment  | 

2 Answers 2

Reset to default 2

If you can explain why you need it, we may find a better solution.

You can use histroy.back() function, i think this would help you.

http://www.w3schools./jsref/tryit.asp?filename=tryjsref_his_back

Document referrer will do this, you can then choose to do what ever you want with this url.

document.referrer

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745375438a4624976.html

相关推荐

  • cookies - How to get previous page URL in javascript? - Stack Overflow

    How can I design a function that will track the previous page a user has viewed. It will be should be d

    3小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信