Andre, I took the code you had and dropped it in to a function and it worked perfectly in IE. I even tried changing the width and height, which worked as well. Two things I had to change to make it work locally are ...setting the value of the image attribute and have some div inside the body with some content (div without content does not work ..because you are accessing the firstChild attribute) .....that set aside, not sure what your image variable has.....can you post little more code ?
//creating new image node
var new_pic = document.createElement("img");
//creating new attribute nodes
var height = document.createAttribute("height");
var width = document.createAttribute("width");
var src = document.createAttribute("src");
//Define values for attribute nodes
height.nodeValue = "500";
width.nodeValue = "500";//image contains link to the picture
//src.nodeValue = image;
src.nodeValue = "code.JPG";
//assigning attribute nodes to the image node
new_pic.setAttributeNode(src);
new_pic.setAttributeNode(width);
new_pic.setAttributeNode(height);
//replacing old node in HTML
document.getElementById("artwork").replaceChild(new_pic, document.getElementById("artwork").firstChild);
Recent Comments