tpra21
07-12-2008, 08:59 AM
I have the below code that is loaded at the beginning of a PHP page. The first loop works great, but the second loop does not work. I am assuming the innerHTML function grabs what is between the <a></a> tags, which in the case of the second loop, is the <img> tag.
Any help would be geatly appreciated. Thanks, Adam
function loadLinks(){
var a = document.getElementsByTagName('a'), rel;
for(var i = 0, len = a.length; i < len; ++i){
content = a[i].innerHTML + "";
shadowbox_config = "shadowbox;height=450;width=700";
if (content == "Contact Information"){
a[i].setAttribute('rel',shadowbox_config);
a[i].setAttribute('title','Contact Info');
}
}
var a = document.getElementsByTagName('a'), rel;
for(var i = 0, len = a.length; i < len; ++i){
content = a[i].innerHTML + "";
shadowbox_config = "shadowbox;height=450;width=700";
if (content == "<img src ='images/map.jpg' border = '0' align = 'middle'></img>"){
a[i].setAttribute('rel',shadowbox_config);
a[i].setAttribute('title','Map Info');
}
}
}
Any help would be geatly appreciated. Thanks, Adam
function loadLinks(){
var a = document.getElementsByTagName('a'), rel;
for(var i = 0, len = a.length; i < len; ++i){
content = a[i].innerHTML + "";
shadowbox_config = "shadowbox;height=450;width=700";
if (content == "Contact Information"){
a[i].setAttribute('rel',shadowbox_config);
a[i].setAttribute('title','Contact Info');
}
}
var a = document.getElementsByTagName('a'), rel;
for(var i = 0, len = a.length; i < len; ++i){
content = a[i].innerHTML + "";
shadowbox_config = "shadowbox;height=450;width=700";
if (content == "<img src ='images/map.jpg' border = '0' align = 'middle'></img>"){
a[i].setAttribute('rel',shadowbox_config);
a[i].setAttribute('title','Map Info');
}
}
}