Previous Message
Next Message

Title Tag for Background Image

Sent by Paul Novitski on 16 February 2005 19:07


At 10:09 AM 2/16/2005, Jeff Gates wrote:
>We use a series of background images on our front page
>(http://americanart.si.edu). Each time a user goes to that page or refreshes
>another image appears randomly.  I'd like to put some descriptive text
>(giving some specific information about that image) when someone rolls over
>it.

Jeff,

I believe the answer to your question isn't found in CSS but in 
scripting.  The purely CSS answer is:  you can't modify an element's title 
with CSS.

What method are you using to supply a different image each time the page is 
downloaded?  Whether server- or client-side script, you can use the same 
technique to supply a correspondingly varying title for the div.

If you're using a server-side script to generate a slightly different page 
each time it's downloaded, I imagine it's inserting an inline style rule, e.g.:

#splash3
         {
         background-image: url(images/<% =aImageURLs(N) %>.jpg);
         }

(Replace vbscript <%...%> convention with tags of your choice.)

Your script is selecting a new image image each time from a scripted array 
or data table.  Add a second column to the array or table for the title 
text for each image, and have the script generate the div as:

         <div id="splash3" title="<%=sTitleText(N)%>">

Similarly, javascript can supply both attributes to the element client-side:

         var oDiv = document.getElementById("splash");
         oDiv.title = aTitles(N);
         oDov.style.backgroundImage = "url(" + aImageURLs(N) + ")";

Paul


______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Previous Message
Next Message

Message thread:

Possibly related: