I catch the click event on certain hyperlinks and instead open a jQuery UI dialog using the href. I return false to avoid the browser doing it too...
$('a.previewable').click(function(){
$('#dialog').html('<img src="'+$(this).attr('href')+'">');
$('#dialog').dialog({
title: 'Preview',
width: 350,
modal: true
});
return false;
});
It works great but the link color开发者_开发知识库 doesn't change to visited when I click on it. How can I tell the browser the link has indeed been visited?
Thanks!
Well, since you did return false
, it hasn't been visited. The best you could probably do is style it.
$(this).addClass('visited');
css
.visited {
color: purple;
}
These scenarios about adding a custom class are weird. What happens the next time the page is refreshed? Wouldn't you have to track all links that had the visited class and persist that information to a backend so it can be restored on subsequent requests? I'd think all those styles would be wiped out the next request since all logic is being done in memory, client side via JavaScript. The browser would normally maintain a cache and persist that information.
精彩评论