Safari Issue with Creatinig new element:

Associate
Joined
31 May 2005
Posts
2,179
Location
Alfreton,Derbyshire
I have this bit of code, which works fine in IE 5+, Opera, Firefox but for some reason it won't work in Safari, it does nothing. Any ideas why?

Code:
var newlink = document.createElement('a');
		newlink.setAttribute('class', "linkopacity");
                //IE Workaround, will be in an if statement soon
		newlink.setAttribute('className', "linkopacity");
                //Set attribute for onClick does not work in IE, so this is a workaround
		newlink.onclick=function(){addElement(this);return false}
		newlink.setAttribute('href', "/images/gallery/" + xx[0].firstChild.nodeValue);
var newimg = document.createElement('img');
		newimg.setAttribute('src',"/images/gallery/" + xx[0].firstChild.nodeValue);
		newimg.setAttribute('height', "75");
		newimg.setAttribute('width', "75");
		newimg.setAttribute('border', "0");
		newlink.appendChild(newimg);
document.getElementById('imgtest').appendChild(newlink);
 
Last edited:
Back
Top Bottom