Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

replacing a <div> node with a <img> node

Status
Not open for further replies.

dorobo88

Programmer
Sep 10, 2002
12
CA
I have this strange problem when replacing a div node with a img node where it adds somehow 5px to my img.
Eg: then click on "test"

As you may notice, the node doesn't fit anymore.
Here's the code to create the img node:

function fCreateImg(name) {
this.imgNodeArr[name] = document.createElement("img");
this.imgNodeArr[name].src = testImg.src
this.imgNodeArr[name].style.height = "245px"; //I've found out that by removing 5px to this value, it fits perfectly.
this.imgNodeArr[name].style.width = "396px";
this.imgNodeArr[name].id = name;

return null;
}

here's the switching code:

function fSwitchNode(oldNode, oldChild, type, name) {
var elmtParent = document.getElementById(oldNode);
var elmtOld = document.getElementById(oldChild);
var newElmnt = this[type + "NodeArr"][name];
newElmnt.id = oldChild;
var replaced = elmtParent.replaceChild(newElmnt, elmtOld);

return null;
}

thks in advance for any suggestions
 
dorobo,

peut etre que, oh sorry, I mean maybe you should try assembling the whole page with the image instead of the text and see if your problem doesn't lay in a layout error.

Tu viens de ou? Gary Haran
 
je viens de Montréal :)

and for your suggestion, I would say that it would remove the biggest part of the dynamic content of my page; replacing nodes.

I'm pretty sure that it would work by directly putting an image instead but that would mean i would have to reload the page.

merci tout de même
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top