yang
yang

Reputation: 508

Show recently visited html pages by any visitor

I want to know how to show a recently visited pages' list with only html and javascript code.

I have a website. It has 100 html files and one html (index.html) for the home page, the others (1.html, 2.html ... 99.html) are sub pages. I want to show a recently visited pages block on my home page. I am trying to not to use php, asp or any other server side languages. Is there any way to do it? Thanks.

Edit1: Thank you for your replies. But it seems I did not make myself clear.

I want all visitors see the list, and the list will not only show pages that he/she has just visited, but all the recent pages that have been visited by any visitor.

Upvotes: 2

Views: 5477

Answers (5)

Pastor Bones
Pastor Bones

Reputation: 7371

You could use cookies to store which pages a user has visited already.

http://jquery-howto.blogspot.com/2010/09/jquery-cookies-getsetdelete-plugin.html

Upvotes: 0

Suraj
Suraj

Reputation: 53


Try tjis with the javascript history object. Check the link below. With the history object you can access the recently viewed pages and manipulate them. But if the user clears the cache then the data is lost.
http://www.javascriptkit.com/jsref/history.shtml

Upvotes: 0

Grrbrr404
Grrbrr404

Reputation: 1805

Its possible to use javascript local storage or css a:visited if you want to create that list for just one user: the viewing user.

You cant share the list with other users.

Upvotes: 0

icktoofay
icktoofay

Reputation: 129109

Save a cookie on the user's computer. Generally, you have something like this (pseudocode):

  • read cookie
  • parse cookie
  • add current page to list (and probably delete old items)
  • save cookie
  • create list from data

Upvotes: 1

Adam Rackis
Adam Rackis

Reputation: 83366

I would look into using HTML5 Local Storage

It's essentially a DBMS stored right on the user's browser. Of course, it's not supported in IE < 8, so if universal cross-browser support is a requirement, this might not work for you.

Upvotes: 1

Related Questions