开发者

Jquery: mark links as visited without opening them?

I have no intention of just altering the link (I hear that's impossible, but if it's not I'd love to know how). I'm fine with adding it to 开发者_如何学运维the the browser history if that needs to be done.

I'd like to loop through all <a>'s on a page and change their state to visited. For example:

$("a").each(function(){
   //mark as visited (somehow?)
});

Essentially creating a "Mark All as Read" button on my page. Any ideas?


Create a link that is visited (i.e. set its href to window.location), and set each of your target links' styles to that newly created link's computed style.


You could ...

1) Try using AJAX (ie. $.get(a.href)), but I don't know if that would actually work.

2) Try styling the links to look visited (by changing their CSS "color" attribute), although this approach won't actually make them in to visited links

3) If neither of those work, you could try doing something like:

3A) Create a hidden IFRAME on the page

3B) Add a target attribute to every A tag on the page to make them point to the hidden IFRAME

3C) Invoke $("a").click() inside that each loop (possibly with a delay of some sort between each one to give the page time to load)

If none of those work, I think you're out of luck.


It's not really possible in the way you want however you could copy the CSS attributes of a:visited to a new class called "visited" or whatever then apply them to the links you want.

$('a').addClass('visited');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜