Having a graphical rather than text-based 'enter' link provides several benefits for free and AVS site owners. These diverse benefits include everything from much wider acceptance by premium AVS services who tend to prefer 'graphically enhanced' sites for inclusion on their link lists, to free site 'warning' pages that strive to divert surfers to a sponsor's site — and stand a much better chance of doing so if their sponsor's banners have a chance to load before the surfer sees that plain text 'enter' link; which is displayed well before any of the page's graphics (including your advertisements) load.
While it's a very simple matter to make a straightforward 'enter' graphic, and indeed, there are many online graphics resources that offer these standard icons as a free download for those who are seriously artistically challenged, today I want to show you an effective technique for making a graphical 'enter' button, complete with a cross-browser JavaScript to provide a 'rollover' effect.
This is one of my favorite techniques; after all, 'happy' buttons enhance a Web page's appearance, and also provide positive feedback to the user. While most JavaScript 'rollover' solutions are simply code-based, and therefore will not work on non-JavaScript enabled browsers, this method will work across all browsers, and is the epitome of 'graceful degradation.' Browsers incapable of rendering the JavaScript will simply display the basic graphic, and as an added bonus, the inclusion of 'alt' tags allows text readers and search engines to parse the link as well. Here's how it's done:
Building the Buttons
The concept behind this technique is really quite simple: we will create two nearly-identical images, altering only the text (foreground) color for this example. For this method to work properly, the images must be the same size, and precisely aligned. While you can accomplish this process with just about any 'paint' program, the following is the procedure with my Web graphics software of choice; Micrografx Picture Publisher 8:
1.) Create a new image by selecting File > New: or by clicking the 'new image' button. I chose to make this 'enter' link 250x50 pixels (a reasonable, and readable, size) and gave it a plain black background — although you could use the Texture tool to fill the blank image with your site's background pattern.
2.) I then used the Text tool to create the 'ENTER' text, selecting a bold, anti-aliased 60pt white Arial font for the primary image. This filled the graphic space completely, leaving a slight border top and bottom that may be cropped to further reduce the file size, but is an 'unnecessary' step for this example. To complete the image, click the 'GIF' button on the main toolbar. The 'GIF Options' dialog box will appear. It is really unnecessary for this to be a transparent image, so I left the default settings intact, ensuring that 'Interlaced GIF' was selected, and then saved this image as 'enter_a.gif'
3.) Next, I chose 'Yellow' (255,255,0) from the 'Color Palette' dialog box, and use the 216-color 'MS Internet Explorer' palette to ensure a web-safe color selection. I then used the 'paint bucket' Fill tool to change the text color to the chosen shade of yellow. Any number of other colors or effects such as gradients, glows, or textures could have easily been used, but I wished to keep this all very simple. A repeat of saving the image by hitting the 'GIF' button, with the only change being the file name ('enter_b.gif') completed the building of our buttons.
Adding the Script
Once the graphics are prepared, the magic begins! After building the Web page and uploading the graphics, the script then needs to be added. For a 'before and after' look, check out the HTML:
HTML HEAD TITLE Graphical Enter Link /TITLE /HEAD>
A href="http://xbiz.com/articles/webmastering/0402/29.html" IMG border="0" src="http://xbiz.com/articles/images/pp8-1/enter_a.gif" alt="ENTER" width="250" height="50" /A>
/CENTER /BODY /HTML>
BODY bgcolor="000000" CENTER>
This basic page code is modified to include the 'rollover' image swap plus a status bar mask. You can see the effect in action by clicking here:
HTML HEAD TITLE Graphical Enter Link /TITLE>
SCRIPT LANGUAGE="JavaScript">
!-- ROLLOVER
var NN3 = false;
function on3(name) {
function on(name) {
function a(txt) {
// ROLLOVER -->
/SCRIPT /HEAD>
BODY bgcolor="000000" CENTER>
A href="http://xbiz.com/articles/mainstream/0402/29.html" onmouseover="on('image1'); a('ENTER');return true;" onmouseout="off('image1'); b();" IMG src="http://xbiz.com/articles/images/pp8-1/enter_a.gif" alt="ENTER" width="250" height="50" border="0" name="image1" /A>
/CENTER /BODY /HTML>
image1= new Image();
image1.src = "http://xbiz.com/articles/images/pp8-1/enter_a.gif";
image1on = new Image();
image1on.src = "http://xbiz.com/articles/images/pp8-1/enter_b.gif";
document[name].src = eval(name + "on.src");
}
function off3(name) {
document[name].src = eval(name + ".src");
}
NN3 = true;
if (NN3) on3(name);
}
function off(name) {
if (NN3) off3(name);
}
self.status = txt
}
function b() {
self.status = ""
}
This is a really simple use of a very powerful script. Additional images can be added to use this script for generating site-wide navigational bars and for other times when a good cross-browser, gracefully degradeable image changing script is needed. Have fun, and good luck! ~ Stephen