http://www.reddit.com/ On this site, if you click and link (sending you away from the site) and then hit the browser "back" button, the area that you clicked originally is highlighted... Neat little means of showing context a bit better than just a visited link color. Anyone know how they are doing this? Thanks in advance! -t
You'd have to look through both their logic.js and prototype.js, but it doesn't look simple. For starters, refer to their highlightLast function. Without analyzing the entire code base, that's as far as I got. My guess is the basic process is you click on the link, then when you come back the server session is still active, so an Ajax call is made that gets the session info for what you clicked, and it changes the style sheet for that link. I'm not sure where or when the information is stored about what link you clicked. function highlightLast () { //Math.random makes safari place nice new Ajax.Request('/aop'+Math.random(), {parameters: "action=last", onComplete:function(request){ var id = request.responseText; var title = document.getElementById("titlerow" + id); if (title) title.className = "highRow"; var close = document.getElementById("close" + id); if (close) close.className = "highRow"; }}); } Code (markup):
They aren't direct links, they call their own script before they redirect you. That's probably when they store what you clicked on.
Oh wow, how did I miss that. I was looking for something complicated, like an onclick event or something.