473,387 Members | 1,897 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

alt tags in images

how would you create a function in the following script that would
change the alt description of the image via a mouseover event. See
end of script. Thanks in advance.

RICK

<script language="JavaScript">
var i = 1;
banner1= new Image();
banner1.src = "image1.jpg";
banner2= new Image();
banner2.src = "image2.jpg";

var links = new Array

links[1] = "http://www.centerforplantconservation.org/testing/image1.jpg"
links[2] = "http://www.centerforplantconservation.org/testing/image2.jpg"

function loadBanner(){

var time= new Date();
hours= time.getHours();
mins= time.getMinutes();
secs= time.getSeconds();
closeTime=hours*3600+mins*60+secs;

// Change this number to increase decrease the rotation speed
closeTime+=3;

Timer();

}

function Timer(){
var time= new Date();
hours= time.getHours();
mins= time.getMinutes();
secs= time.getSeconds();
curTime=hours*3600+mins*60+secs
if (curTime>=closeTime){
if (i < 5){
i++;
document.banner.src = eval("banner" + i +
".src");
}
else{
i = 1;
document.banner.src = eval("banner" + i +
".src");
} loadBanner();
}
else{
window.setTimeout("Timer()",1000)}

}

function clickLink(){
top.location = links[i]
}

function altimage() {
var ???????
????????????
}
</script>
Jul 20 '05 #1
2 9190
Vjekoslav Begovic wrote on 08 aug 2003 in comp.lang.javascript:
To change alt attribute of image:

myImage.setAttribute("alt", "MyAltText");
Slightly OT-ing the OP:

<img src="..."
alt="this is my standard alt text"
standard="this is my standard alt text"
alternative="this is my alternative alt text"
onclick="this.alt=(this.alt==this.alternative)?
this.standard:this.alternative"


IE6 tested

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #2
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
<snip>
Slightly OT-ing the OP:

<img src="..."
alt="this is my standard alt text"
standard="this is my standard alt text"
alternative="this is my alternative alt text"
onclick="this.alt=(this.alt==this.alternative)?
this.standard:this.alternative"

IE6 tested


It is very questionable whether adding your own HTML attributes is a
good idea (it should certainly make validating a page against a standard
HTML DTD troublesome).

However, if this technique is used, it is worth mentioning that a number
of browsers do not follow IE in making these attributes into named
properties of the element. They are often (but not always) made
available as attribute nodes so slightly wider browser support can be
achieved by exclusively using the - getAttribute - method of the element
when accessing this type of made up HTML attribute.

Obviously support for providing this type of additional data can be
increased to 100% of JavaScript capable/enabled browsers merely by
defining the data in the JavaScript code (in whatever data structure
suites the problem).

The original question seems to be an attempt to use the ALT attribute as
a vehicle for tool-tip type information. This is widely considered to be
an inappropriate use of the ALT attribute, encouraged by the fact that
some user agents present the contents of the ALT attribute in a tool-tip
style pop-up box. The regulars on HTML groups will usually try to
convince people that the TITLE attribute is the correct vehicle for
tool-tip type information and that the ALT attribute should be a text
alternative to the image, so it would only make sense to change the ALT
attribute text if the image was also swapped.

Richard.
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: jeff | last post by:
Hiya im trying to pull tags off a website using python ive got a few things running that have the potential to work its just i cant get them to becuase of certain errors? basically i dont...
7
by: Ana | last post by:
I just ran a report on a site I'm redesigning and came up with all these missing height/width tags. How important are they? Should I go through the trouble of making sure they're there? Ana
8
by: George Adams | last post by:
I'm just starting to pick up some CSS knowledge after about 10 years of plain ol' HTML coding. I'm finding it easiest to learn CSS by example, so I'm following with interest the tricks I see done...
2
by: Got2Go | last post by:
Hello, I am trying to come up with a function that will search the source of the page for a specific string. If that string is found, then have it modify specific tags inside of a table and...
39
by: fleemo17 | last post by:
I'm wondering whether it's better to leave an alt tag blank (alt=" ") or specify something like "alt='spacer'" when referring to objects that merely help the layout of the page? -Fleemo
3
by: Julie | last post by:
I've got one that I've spent all to much time on: I have an aspx page that includes the following (code behind is C#): <asp:Imagebutton runat="server" ImageUrl='<%# Application +...
0
by: lawrenceS59 | last post by:
Hi all, I'm fairly new to web development so bare with me. The html page that i've created isn't working and i can't figure out why. I'm guessing there are some rules that need to be followed...
2
by: AR123 | last post by:
I want to convert my website tables layout to div tags as someone told me its easier to make changes etc etc I just need some help in getting started with this and what to put in the stylesheet. the...
6
by: UKuser | last post by:
Hi Folks, Is there a way, I can hide images through CSS and then display the alt tags? I want to create a Javascript free CSS/Cookies approach to doing text- only. I've set the style for...
8
by: azjudd | last post by:
Thank you in advance for your help on this one. I'm using named anchor tags on a FAQ page with questions listed at the top and answers below; a standard jump-to feature. However, anytime an anchor...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.