A
Andrew Poulos
On window load I'm running some javascript to add an image to a DIV. The
image is being added/created but it is about 18 or so pixels further
down the screen than expected. If I code the IMG tag, including a style
attribute, directly into the DIV's HTML the image displays where I
expect it to i.e. in the top left corner.
Is there something about DOM methods that affects positioning or is
there something else I've missed?
The relevant js looks like this:
if (document.getElementById("up")) {
myimg = document.createElement("IMG");
} else {
return;
}
document.getElementById("up").appendChild(myimg);
myimg.src = "q.png";
myimg.style.position = "absolute";
The relevant HTML is simply this:
<div id="up" style="position:absolute; left:40px; top:40px; width:600px;
height:80px;>
</div>
Andrew Poulos
image is being added/created but it is about 18 or so pixels further
down the screen than expected. If I code the IMG tag, including a style
attribute, directly into the DIV's HTML the image displays where I
expect it to i.e. in the top left corner.
Is there something about DOM methods that affects positioning or is
there something else I've missed?
The relevant js looks like this:
if (document.getElementById("up")) {
myimg = document.createElement("IMG");
} else {
return;
}
document.getElementById("up").appendChild(myimg);
myimg.src = "q.png";
myimg.style.position = "absolute";
The relevant HTML is simply this:
<div id="up" style="position:absolute; left:40px; top:40px; width:600px;
height:80px;>
</div>
Andrew Poulos