![]() |
|
#1
|
|||
|
|||
|
Hi,
My porblem is the following: I am declaring a new image node (which I attach to a child div node) and "image" is the image source I am passing to it. [code:nvnnn5us11] var Zeimg = document.createElement("img"); Zeimg.setAttribute("src", image); Zeimg.setAttribute("name", zimZe); Zeimg.className="master"; Zeimg.style.top = "0px"; Zeimg.style.left= "0px"; Zeimg.setAttribute("id",zimZe); Zeimg.style.visibility = "visible"; DivMaster.appendChild(Zeimg); [/code:nvnnn5us11] where DivMaster is the child node, and then I attach the child to the body with body.bodyRef.appendChild(DivMaster) So far so good works fine. So where is the problem ? I am now changing the src of the image without recreating the child node or the image node. (after having created it) I am doing: [code:nvnnn5us11] if(ob(zimZe)) ob(zimZe).src=image;[/code:nvnnn5us11] where again image is the address of my picture and ob is just a function to retrieve my object id. There is no problem in mozilla the new image expands the child node. In internet explorer however it keeps the previous image size in memory so that the new picture has the size of the first one. NOT GOOD. Of course I could just give the dimensions manually, I however would like something more clever. I thought of destroying the image node and recreating another node wich I could re-attached to the divMaster node. Any idea on how I can do that ? I mean I have no trouble killing the thing (niark niark) but I am stuck in the way of re-attaching. Any better idea ? (Hope it's clear enough and that you understood my problem ...) Cheers ps: On the website: the "forgot Pass" doesn't work. It just opens a new window with the forum in it... I lost my pass for a previous nickname so sorry I had to create yet another nick. |
|
#2
|
|||
|
|||
|
First of all try using `setAttribute("src", image)`. If that doesn't work you could try your other idea. I'm not sure though what problems you have with that idea, could you elaborate?
- [url="http://neo.dzygn.com/"]Mark[/url:2jc7a3k4jj] |
|
#3
|
|||
|
|||
|
aaaah a quick answer ;-) thanks
Ok I tried this: [code:ltjhgqsn2n]if(ob(zimZe)) ob(zimZe).setAttribute("src", image);[/code:ltjhgqsn2n] And again it works fine under mozilla, but with IE it keeps the width and the height of the previously opened image. The problem with passing directly the height and the witdh is that it's highly annoying. I mean it's not efficient at all. I might as well just not create the divs on the fly right .. Also I have to know in advance the size of the picture. My aim is to have a script which just runs with minimum input from the user, ie me (no point of making scripts otherwise) to have something automatic that can run on its on. Like imaging I am doing a directory listing where I have pictures, how can I know the sizes of the pictures ?. I want something friendly, and so far IE hasn't been a good friend ! Thanks |
|
#4
|
|||
|
|||
|
One solution (solution B) is to kill the mother node div and then to recreate it at the same position. That involves picking-up the coordinates but that's fairly easy.
[code:yoilb6q6yq] bodyRef.removeChild("divname");[/code:yoilb6q6yq] My second solution as exposed earlier is to kill the picture node and then re-attach it to the divID node and so far I had troubles, but I finally managed to get it right: [code:yoilb6q6yq] ob(zimZe).parentNode.removeChild(ob(zimZe)); var Zeimg = document.createElement("img"); Zeimg.setAttribute("src", image); Zeimg.setAttribute("name", zimZe); Zeimg.className="master"; Zeimg.style.top = "0px"; Zeimg.style.left= "0px"; Zeimg.setAttribute("id",zimZe); Zeimg.style.visibility = "visible"; ob(divID).appendChild(Zeimg); [/code:yoilb6q6yq] Which works fine in both mozilla and IE. (the other browsers can die) It helped talking about it ;-) So to conclude with this solution the code looks like crap so solution B is nicer I am lucky that in my case I just have to add two lines or so to my script: [code:yoilb6q6yq] fixtop = "100px"; fixleft = "100px"; if (ob(zim)) { fixtop = ob(zim).style.top; fixleft = ob(zim).style.left; killterm(zim); } [/code:yoilb6q6yq] and then I just recreate the all div etc.. just as I would if it wasn't existing. (the other problem being I have a lot of other things in it requiring more attention and it's just as easy to redeclare everything.. it could have been much nicer but hey.. that the standards for you... Finally it's worthwhile knowing that IE keeps the sizes in memory. And once again WHY GOD WHY DID IT HAVE TO BE DIFFERENT ?!?! So problem solved thanks Matt. (unless you have something more elegant) |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|