...

View Full Version : Adding image before links in a div



jsammarco
03-20-2009, 10:00 PM
I'm rusty on my javascript and know enough to get by but I have been trying to firgure this out for days. I want to add linkable images before each link within a div. Basicly a preview button to get the links href to play within the website in a flash audio player. but all I want to know is how to get the images before the links. This is what I have.


for (var i=0; i<document.links.length; i++) {
document.links[i].target = document.links[i].target.replace("_self","_blank");
var linkurl = document.links[i].href.value;
var saveimg = document.createElement('img');
saveimg.setAttribute('src', 'http://www.babybums.co.uk/Portals/69/orange-star.gif');
saveimg.setAttribute('style','width:16px!important;height:12px!important;border:none!important;');
var parent = document.getElementByName('list');
parent.insertBefore(saveimg);
}

Any help would be great,
Thanks in advance,
Joe

TinyScript
03-20-2009, 10:18 PM
parent.insertBefore(saveimg)

I think you want

document.appendChild(saveimg)

jsammarco
03-21-2009, 12:01 AM
But I want it before the link not after, but regardless that doesn't work either.

any other ideas?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum