Do You Think This Is Possible?

P

Prisoner at War

Hi, Folks!

Do y'all think it's possible to use JavaScript to alternate the text
of the ALT attribute of an <img> tag?

And is there a way to have that ALT's text show up in Opera and
Firefox the way it does in Internet Explorer?

So that with an onMouseOver it will appear as if the image of a dog,
for example, is saying, alternately, "moo," "meow," "a little to the
left," and "ah, that hits the spot"?

BTW, I read somewhere that Opera is the most JavaScript (ECMAScript or
something) compliant browser there is. True?


As always, many thanks for all your time and help!
 
J

Joost Diepenmaat

Prisoner at War said:
Hi, Folks!

Do y'all think it's possible to use JavaScript to alternate the text
of the ALT attribute of an <img> tag?

Yes. But really; don't.
And is there a way to have that ALT's text show up in Opera and
Firefox the way it does in Internet Explorer?

If any browser still does that, it's very old behaviour that's widely
regarded as wrong. You should use TITLE instead.
So that with an onMouseOver it will appear as if the image of a dog,
for example, is saying, alternately, "moo," "meow," "a little to the
left," and "ah, that hits the spot"?

That's very much not what a title attribute is supposed to be used for,
so you probably shouldn't expect it to work everywhere. Why don't you
try it and see if it does.
BTW, I read somewhere that Opera is the most JavaScript (ECMAScript or
something) compliant browser there is. True?

Dunno. In practice the implementations of the ecma 262 standard in the
"big" browsers (mozzilas, ie, opera, safari and deriviates) are all
pretty much complete - the only thing I can think of right now is that
IE won't allow the elements in an array literal to be ended with a
comma.
 
T

Thomas 'PointedEars' Lahn

Joost said:
Yes. But really; don't.

Whether that recommendation makes sense would depend on the task to be
accomplished, of course. If images are to be switched so that the next
image shows a different object than the previous image, it would not only
be possible but prudent to change the `alt' attribute value as well, so that
the alternative text changes for that image.

This should be done as follows:

imgRef.alt = "newValue";


BTW, it's _Mozilla_.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,151
Latest member
JaclynMarl
Top