Mick Wansey Posted April 8, 2009 Share Posted April 8, 2009 I have this code and if anyone can help me I would like it know how you can add alt text to it if it is possibe tyimages = new Array(); images[0] = "<img src ='images/b3200.jpg'>"; images[1] = "<img src ='images/b4200.jpg'>"; images[2] = "<img src ='images/fruits200.jpg'>"; index = Math.floor(Math.random() * images.length); document.write(images[index]); Link to comment Share on other sites More sharing options...
Ingolme Posted April 8, 2009 Share Posted April 8, 2009 I might be misunderstanding your question, but if you're asking about the aternate text for the image, just add the "alt" attribute to the <img> tag. images = new Array();images[0] = "<img src='images/b3200.jpg' alt='Alternate text'>";images[1] = "<img src='images/b4200.jpg' alt='Alternate text'>";images[2] = "<img src='images/fruits200.jpg' alt='Alternate text'>";index = Math.floor(Math.random() * images.length);document.write(images[index]); Link to comment Share on other sites More sharing options...
Mick Wansey Posted April 9, 2009 Author Share Posted April 9, 2009 that hasn't seemed to work I might be misunderstanding your question, but if you're asking about the aternate text for the image, just add the "alt" attribute to the <img> tag.images = new Array();images[0] = "<img src='images/b3200.jpg' alt='Alternate text'>";images[1] = "<img src='images/b4200.jpg' alt='Alternate text'>";images[2] = "<img src='images/fruits200.jpg' alt='Alternate text'>";index = Math.floor(Math.random() * images.length);document.write(images[index]); Link to comment Share on other sites More sharing options...
mstransky Posted April 9, 2009 Share Posted April 9, 2009 that hasn't seemed to workI have a number of ready js codes, are you trying to display random images?I use this setup when making my arraysadblock[0]=......adblock[1]=......adblock[2]=......adblock[3]=......adblock[4]=......adblock[5]='<a href="graphics/image5.jpg" rel="nofollow"><img src="graphics/image5.jpg" width="120" height="60" border=0 alt="Display alt text for 120x60as6" /></a>'adblock[6]=......if you need a full script just let me know Link to comment Share on other sites More sharing options...
Ingolme Posted April 9, 2009 Share Posted April 9, 2009 Maybe you're referring to tooltip text, in that case you use the title attribute: images = new Array();images[0] = "<img src='images/b3200.jpg' alt='Alternate text' title='Image 1'>";images[1] = "<img src='images/b4200.jpg' alt='Alternate text' title='Image 2'>";images[2] = "<img src='images/fruits200.jpg' alt='Alternate text' title='Image 3'>";index = Math.floor(Math.random() * images.length);document.write(images[index]); Alternate text refers to text that appears if the image is unable to be loaded. Link to comment Share on other sites More sharing options...
Mick Wansey Posted April 9, 2009 Author Share Posted April 9, 2009 ty that has worked much appreciated Maybe you're referring to tooltip text, in that case you use the title attribute:images = new Array();images[0] = "<img src='images/b3200.jpg' alt='Alternate text' title='Image 1'>";images[1] = "<img src='images/b4200.jpg' alt='Alternate text' title='Image 2'>";images[2] = "<img src='images/fruits200.jpg' alt='Alternate text' title='Image 3'>";index = Math.floor(Math.random() * images.length);document.write(images[index]); Alternate text refers to text that appears if the image is unable to be loaded. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.