views:

46

answers:

2

Hi, Is there way in jetpack(mozilla's extension development framework) , to find the the visited links in a page?

BTW: jquery's a:visited works in firebug , but not in jetpack. i'm guessing it's part of jetpack's security.

+1  A: 

You can't read whether a particular link is selected from JavaScript, you can only do it indirectly, using a Selector. Consequently a:visited is not supported by jQuery/Sizzle; if it works for you, that's only because jQuery is farming off the selector to the browser's native querySelectorAll interface; on older browsers that don't support Selectors-API Level 1, it won't work.

You can try document.querySelectorAll('a:visited') directly to see whether the environment allows history reading. The spec allows a browser to block it, and certainly IE does; I don't know about JetPack.

The nasty hack that was used to snoop history previously, which might still be applicable, is to add a rule to the stylesheet targeting visited links and see if the element has been matched by looking at its currentStyle/getComputedStyle (.css in jQuery).

bobince
+1  A: 

Except the solution suggested by @bobince has been eliminated as a security issue in the latest versions of Firefox.

mcepl