Prepare!

Lee Harvey's Zombie Hit Parade

UserJS to fix link underline colors

As most of us know, Opera has a very strict interpretation of the standards. One example is the underline color used for links when the deprecated <font color="whatever"> tag is used inside a link. If you've used Opera long enough, I'm sure you've run across sites whose links just look wrong -- the text is one color, but the underline color is something completely different. For example, see the red headlines on the DrudgeReport, or the red section headers on the NYTimes, or even the Sports section on Excite.

To cope with this, I've developed the following User JavaScript that will seek-out these links, and attempt to correct the visual soup...

[B]document.addEventListener("load",
   function() {
      if (!document.getElementsByTagName("font").length) return;
      for (var i = 0, link; link = document.links[ i ]; i++) {
         if (link.style.color) continue;
         var fonts = link.getElementsByTagName("font");
         var fontRE = /<font[^>]*color=[\w\W]*$/i;
         if (!fonts.length || !link.innerHTML.match(fontRE, "")) continue;
         for (var n = 0, c; n < fonts.length; n++) {
            if (c = fonts[n].getAttribute("color")) {
               link.style.color = c;
               break;
            }
         }
      }
   }, false);[/B]


...when complete, the modified links will resemble both MSIE and Firefox rendering.

I hope you find it useful.

Tim's Top 10 Rendering Engine Bugs ListUserJS to access Optus.net.au

Comments

Laurens BosscherDolfhinDC Sunday, August 28, 2005 11:26:44 PM

Very Nice!
I added it to my UserJS and it seems to work perfectly fine bigsmile

Thanks bigsmile

Lee HarveyLee_Harvey Sunday, August 28, 2005 11:26:44 PM

Please note, an optimized version of this script has been uploaded to UserJS.org, see:

<http://userjs.org/scripts/general/fixes/fix-font-tag-underline&gt;

Thanks for the kind feedback.

Write a comment

New comments have been disabled for this post.