View Full Version : Swiss Army Image Slideshow: alt attribute

04-18-2007, 06:01 PM
1) Script Title: Swiss Army Image Slideshow

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex14/swissarmy/index.htm

3) Describe problem: Hi again. I've decided that I want to have alt text for the images in my slideshow, so I added the "use_alt=1" property, but I'm not seeing any alt text when I mouse over the images. It occurred to me that maybe this was because I also had it set to show no descriptions, so I took that property out. But then it shows the description and still no alt text.

So, what did I do wrong, and is it possible to have no descriptions display on the web, but still use the descriptions as alt text? Here's my slideshow:

var slides=[];
slides[0] = ["image1.jpg", "Garden of the Gods"];
slides[1] = ["image2.jpg", "Garden of the Gods"];
slides[2] = ["image3.jpg", "Garden of the Gods"];
slides[3] = ["image4.jpg", "Garden of the Gods"];
slides[4] = ["image5.jpg", "Garden of the Gods"];
slides[5] = ["image6.jpg", "Garden of the Gods"];
slides[6] = ["image7.jpg", "Garden of the Gods"];
slides[7] = ["8.jpg", "Garden of the Gods"];
slides[8] = ["9.jpg", "Garden of the Gods"];
slides[9] = ["10.jpg", "Garden of the Gods"];
slides[10] = ["11.jpg", "Garden of the Gods"];
slides[11] = ["12.jpg", "Garden of the Gods"];
slides[12] = ["13.jpg", "Garden of the Gods"];
slides[13] = ["14.jpg", "Garden of the Gods"];
slides[14] = ["15.jpg", "Garden of the Gods"];

I mainly want the alt text for search engine purposes, so if the user can't see them but search engines can, that's fine, too.


04-18-2007, 06:13 PM
The alt attribute doesn't do anything onmouseover. That's because well, it doesn't, never has except in IE. I had to choose how to set this up when I wrote it and chose to follow the way all other browsers do it. Fortunately IE can also do it that way. That is via the title attribute. So, what you want is really:




although you can use both. What the alt attribute is supposed to do and does well is provide text content if the image is missing for any reason.

As far as I know you can use either or both of these with:


but, you must configure the descriptions in the array or else there will be no text to use for title or alt.

Don't forget to use:


04-18-2007, 06:46 PM
Great! That worked.

Thanks again for all your help!

04-18-2007, 07:21 PM
I missed an important point in your posts about this:

I mainly want the alt text for search engine purposes, so if the user can't see them but search engines can, that's fine, too.

There are several approaches one can take here but having the script use alt or title isn't one of them as, search engines rarely see what scripts do because it is written to the page dynamically, not hard coded.

I think the best thing to do would be to make up a division in the body and fill it with the descriptions:

<div id="the_descriptions">
If you had javascript enabled you would be seeing a slide show of:<br>
Description one<br>
Description two<br>
etc., etc.

And, in the head of the page have:

<script type="text/javascript">
document.write('<style type="text\/css">\n\
#the_descriptions {\n\

That way they will be hard coded to the page and visible when javascript is disabled. Just the sort of thing that a search engine wouldn't ignore. It also would be a way of telling the non-javascript enabled folks what they are missing.