473,609 Members | 1,851 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="JavaS cript">
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.centerforpl antconservation .org/testing/image1.jpg"
links[2] = "http://www.centerforpl antconservation .org/testing/image2.jpg"

function loadBanner(){

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

// 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*3 600+mins*60+sec s
if (curTime>=close Time){
if (i < 5){
i++;
document.banner .src = eval("banner" + i +
".src");
}
else{
i = 1;
document.banner .src = eval("banner" + i +
".src");
} loadBanner();
}
else{
window.setTimeo ut("Timer()",10 00)}

}

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

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

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

<img src="..."
alt="this is my standard alt text"
standard="this is my standard alt text"
alternative="th is is my alternative alt text"
onclick="this.a lt=(this.alt==t his.alternative )?
this.standard:t his.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******** ************@19 4.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="th is is my alternative alt text"
onclick="this.a lt=(this.alt==t his.alternative )?
this.standard:t his.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
1756
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 what to download the images and all the stuff just the html and then work from there, i think its timing out because its trying to downlaod the images as well which i dont what to do as this would decrease the speed of what im trying to achieve, the...
7
2966
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
7501
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 at sites like www.csszengarden.com and others. One common technique I see on many sites is to replace a bit of text with an image - something like this: ------------------------------------------------
2
1708
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 display a link on the page. This link, when clicked will then restore the modified tags back to their original values.
39
4971
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
1353
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 + "/images/up.gif" %>' /> When rendered, the image src tag isn't there (at all!). If I change to:
0
6425
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 when putting xml between the <textarea></textarea> tags. The textarea and the submit buttons are located inside <form> tags. When a button is pressed it calls a jsp page to do the processing needed. For some xml content it works nicely....for others i...
2
1981
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 code below is how it looks just now. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Angela...
6
2433
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 images display:none (I know it still requires CSS) and then don't display my main stylesheet. But is there a way to display the alt tags if a certain attribute is applied to images?
8
5130
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 tag link is used, whether it be a question down to an answer or an answer back to the list of questions, I lose the banner div, a good portion of of my MenuDv disappears, and white space is added to the bottom of my page. You can see my FAQ page...
0
8579
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8555
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8232
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8408
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7024
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4032
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4098
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2540
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1686
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.