Forum Moderators: open

Message Too Old, No Replies

using DOM to set id of an image in safari?

         

CgiBin

5:15 pm on May 24, 2005 (gmt 0)

10+ Year Member



I have a block of code that is creating a list of names with a small img icon next to them that when clicked is supposed to remove them from the list.

Everything was working perfectly in IE and FF, however when I checked safari I'm getting errors:
Value undefined (result of expression myImg.setAttribute) is not object.

var myImg = new Image(10, 10);
myImg.src = '/artwork/minus.gif';
myImg.setAttribute('id', 'remU_'+ uID);
myImg.className = "minusImg";
myImg.title = 'Remove user';
myImg.onclick = function() { removeUser(this.id); };

I've tried using createElement('img'); and that doesn't work.

Any ideas?

CgiBin

5:25 pm on May 24, 2005 (gmt 0)

10+ Year Member



Bah... figures I solve it a few min after posting...

var myImg = document.createElement('img');
myImg.setAttribute('id', 'remU_'+ uID);
myImg.setAttribute('src', '/artwork/minus.gif');
myImg.className = "minusImg";
myImg.title = 'Remove user';
myImg.onclick = function() { removeUser(this.id); };