Electric Type

Multimedia

About Us

News

Help

The Visited Link Color Bonanza

Page 3 — Behind the Scenes

For those who care, here's how it works. The initial <STYLE> block defines the unvisited and visited link colors (white and light gray, respectively).

The first JavaScript is a work-around for an Internet Explorer 3.x bug (PC only). This script guarantees that links in IE 3 will be white and not the default color. You should know, however, that if scripting is turned off in IE 3, your links will be the default color.

The second JavaScript defines a variable called vlink. For any browser except Netscape or IE 4.0+ (in other words, any browser that doesn't support multiple visited link colors), use this: vlink = "<FONT COLOR=#FFFFFF>". Otherwise, vlink will be empty.

In the <BODY> of the page, the code for each link must be in this order:

  1. The <A> with CLASS="nav". This sets the link colors.

  2. An optional <FONT> tag for setting typeface and size. Don't define a color here!

  3. The beginning of the <SCRIPT>.

    Important: If your link is within an HTML table, these first three bits of code must be on the same line as the <TD> that opens that particular table cell. Otherwise, you may get odd behavior in Navigator 3.x.

  4. The document.write that inserts the value of vlink. For browsers that don't support multiple visited link colors, <FONT COLOR=#FFFFFF> is added to ensure white links.

    This approach is necessary because of the browser bugs we noted on the previous page. If we inserted <FONT COLOR=#FFFFFF> for Communicator 4.0+ and IE 4.0+, they would treat the HTML as more important than the CSS, and thus, we'd never see the CSS-defined visited link color. Silly, isn't it?

  5. The end of the <SCRIPT>.

  6. A <NOSCRIPT> for all browsers that either don't support JavaScript or have it turned off. <FONT COLOR=#FFFFFF> ensures that the links are white.

  7. The actual link text.

  8. The closing </FONT> and </A> tags.
I know, I know. It's absurd that it takes this much code to accomplish something so simple. But there it is.

Visited link colors are a good thing. They help users understand where they've already been, and they make navigation easier. And now you have a slightly larger palette to work with.


Dynamic HTML  

Frames  

HTML Basics  

Stylesheets  

Tables  

XML  

Javascript  

Database Connections  

Intro To Perl  

HTML 4.0  

User Blogs

Screen Shots

Latest Updates

Contact Us

Valid HTML 4.01!
Valid CSS!

Breadcrumb

© ElectricType
Maintained by My-Hosts.com
Site map | Copyright | Disclaimer
Privacy policy | Acceptable Use Policy
Legal information.