Jquery:将链接标记为已访问但未打开它们? [英] Jquery: mark links as visited without opening them?

查看:169
本文介绍了Jquery:将链接标记为已访问但未打开它们?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无意改变链接(我听说这是不可能的,但如果不是我想知道如何)。如果需要这样做,我可以将它添加到浏览器历史记录中。

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.

我想循环遍历所有< a> 在页面上并将其状态更改为已访问。例如:

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?

推荐答案

你可以......

1)尝试使用AJAX(即$ .get(a.href)),但我不知道这是否真的有用。

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

2)尝试样式化链接以查看访问(通过更改其CSS颜色属性),虽然这种方法实际上不会使它们进入访问过的链接

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)如果两者都没有这些工作,你可以尝试做类似的事情:

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

3A)在页面上创建一个隐藏的IFRAME

3A) Create a hidden IFRAME on the page

3B )向页面上的每个A标签添加一个目标属性,使它们指向隐藏的IFRAME

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

3C)调用$(a)。click()里面的那个每个循环(可能在每个循环之间有某种延迟,以便给页面加载时间)

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.

这篇关于Jquery:将链接标记为已访问但未打开它们?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆