...

View Full Version : Alt Attribute in Image Array



infisoul
08-29-2008, 04:27 PM
I would like to add an "Alt Attribute" to each image.
All images on the page apper in the same spot (like a gallery) so one replaces the other;
using the function:


function rightImage(theImage){

if(imageNum>19){
imageNum=-1}

theImage.src=myImage[imageNum+1];
imageNum++


}

I tried adding alt to the array:

myImage= new Array(20)

myImage[0]="images/copyRight_f001.jpg"
myimage[0].setAttribute('alt','tuna with mango');
myImage[1]="images/copyRight_f002.jpg"
myimage[1].setAttribute('alt','scallop ceviche');
...
but then page gives an error



the page and source can be viewed at www.sashagitin.com/food
Thank you very much for your help.

abduraooft
08-29-2008, 04:56 PM
myImage[0]="images/copyRight_f001.jpg"
myimage[0].setAttribute('alt','tuna with mango');
myImage[1]="images/copyRight_f002.jpg"
myimage[1].setAttribute('alt','scallop ceviche'); Neither the above code nor the error specified is visible to me in the page given above.

infisoul
08-29-2008, 05:20 PM
sorry here is the page with error:
http://sashagitin.com/beta/food/indexTest.html

it's a bit confusing. Because it interacts with another function that plays the gif animation while image is loading.

so when array doesn't include "alt" it workes fine
myImage[0]="images/copyRight_f001.jpg"

but with alt
myimage[0].setAttribute('alt','tuna with mango');

it doesn't display the image and freezes at gif animation

thanks

rangana
08-30-2008, 06:33 AM
JS is case-sensitive. myimage is different from myImage.

Hope that makes sense.

infisoul
08-31-2008, 03:47 AM
Thank you rangana for noticing the case... i changed it but.... it still doesn't work....

Would anyone have a sample of the whole page where alt attribute in the image is assigned by Javascript?
Million Thanks.

infisoul
08-31-2008, 03:50 AM
Also I have a SEO question on the same topic. Does google or other engines read Alt text assigned to the image in javascript ???

rangana
08-31-2008, 06:18 AM
Have you updated your page already? It seemed that I (still) see the typo:


myimage[0].setAttribute('alt','tuna with mango');
myImage[1]="images/copyRight_f002.jpg"
myimage[1].setAttribute('alt','scallop ceviche');


Change highlighted to myImage.

oesxyl
08-31-2008, 06:30 AM
Thank you rangana for noticing the case... i changed it but.... it still doesn't work....

Would anyone have a sample of the whole page where alt attribute in the image is assigned by Javascript?
Million Thanks.
you have few errors in javascript:


myImage[0]="images/copyRight_f001.jpg"
myimage[0].setAttribute('alt','tuna with mango');
myImage[1]="images/copyRight_f002.jpg"
myimage[1].setAttribute('alt','scallop ceviche');


imageNum = 19; must be in code before first place where you use it, more exactly all declaration including myImage.

your first concern about seo must be in layout, you use a 5 depth table, hard to read by google bot.

best regards

infisoul
09-01-2008, 04:49 PM
setAttribute('alt','text');
Simply didn't work ( and i did change case)

however what worked was a separate array
imageNum=0


myAlt= new Array(20)

myAlt[0]="tuna1"
myAlt[1]="scallop2"
myAlt[2]="tuna3"
myAlt[3]="shrooms"
myAlt[4]="tofu"
myAlt[5]="radish"

and just one more line added to the function
theImage.src=myImage[imageNum+1];
theImage.alt=myAlt[imageNum+1];

sample can be seen in source http://www.sashagitin.com/beta/food/codeTest.html

alt text changes on main image when arrow is used.

However after testing in with Linxs and other SEO tools it turned out that Alt Text in Javascript is OBSOLUTELY USELESS. Google bot simply doesn't see it.

infisoul
09-01-2008, 04:57 PM
oesxyl : you wrote: your first concern about seo must be in layout, you use a 5 depth table, hard to read by google bot.
Any source that is not 10 years old suggests that google bot has no problem with nested tables. PLEASE prove sopportive evedance. is you know otherwise

My problem is that the whole website is only visual and any actual text will desturb prospects from viewing the images. In the eyes of google the site is almost empty. Thats why i am trying to create alt text. However creating alt text in javascript did not help. ...

oesxyl
09-01-2008, 07:09 PM
oesxyl : you wrote: your first concern about seo must be in layout, you use a 5 depth table, hard to read by google bot.
Any source that is not 10 years old suggests that google bot has no problem with nested tables. PLEASE prove sopportive evedance. is you know otherwise
prove me that this is more readable:


<table>
<tr>
<td>
<table>
<tr>
<td>
<table>
<tr>
<td>
<table>
<tr>
<td>
<table>
<tr>
<td>
<img ....


then this:


<div>
<img.....

there are a lot of arguments seo and non-seo against this.


My problem is that the whole website is only visual and any actual text will desturb prospects from viewing the images. In the eyes of google the site is almost empty. Thats why i am trying to create alt text. However creating alt text in javascript did not help. ...
is visual because your thinking is visual, :), google have google image bot and you can make your gallery more bot friendly and overall is a matter of proper design.



<div id="p1" class="dh">
<img src="p1.jpg" alt="p1 alt" title="p1 title" />
</div>
<div id="p2" class="dh">
<img src="p2.jpg" alt="p1 alt" title="p1 title" />
</div>




.dh { display: none; }


and then you can use javascript to make #p1 display: block when the page is loading and as far as the user click of one of the buttons to navigate, you change none to block and block to none to display each image.

best regards

Samhain13
09-03-2008, 01:51 AM
If I may butt in...

The alternate text attribute is not meant for SEO anyway, it's there for accessibility reasons-- although SEO and accessibility are not mutually exclusive. But considering that robots' reading of alt text is already a bit iffy, it's a lot less likely that javascript-generated alt text will be of help where SEO is concerned.

+1 on oesxyl's hidden content solution. Cheers! :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum