I need to set the a:visited CSS to whatever color the normal a is set to.
What I want to be able to tell the browser is, for the visited links, use the same
Presto:
$(function(){
var sheet = document.styleSheets[document.styleSheets.length-1];
sheet.insertRule(
'a:visited { color:'+$('a:link').css('color')+'; }',
sheet.length
);
});
I've tested and can confirm this works in Chrome. Keep in mind however, which sheet
you're adding the rules to -- make sure its media attribute applies to the media that you care about. Additionally, if you have any rules that override the a
coloring, this likely won't work properly -- so make sure your stylesheets are clear of that.
I'm not so sure this is a very wise practice anyways. Personally, I always explicitly define my link colors for every site.
PS:
Apparently IE (don't know which versions) insists on their own syntax:
sheet.addRule('a:visited', $('a:link').css('color'), -1);