Forum Moderators: open

Message Too Old, No Replies

Space added below javascript in IE6

         

terrybarnes

3:40 pm on Dec 23, 2007 (gmt 0)

10+ Year Member



Now I've had this happen before but I can't remember what I did then to resolve the issue!

I have a random image script but when I add that to a table cell and view in IE6 it seems to add a 4 pixel space below the image. All other browsers appear ok.

Any ideas would be much appreciated?

<SCRIPT LANGUAGE="Javascript"><!--
function image() {
};

image = new image();
number = 0;

// imageArray
image[number++] = "<img src='images/1.gif' border='0'>"
image[number++] = "<img src='images/2.gif' border='0'>"
image[number++] = "<img src='images/3.gif' border='0'>"
image[number++] = "<img src='images/4.gif' border='0'>"
image[number++] = "<img src='images/5.gif' border='0'>"
// keep adding items here...

increment = Math.floor(Math.random() * number);

document.write(image[increment]);

//--></SCRIPT>

encyclo

4:08 pm on Dec 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Does adding
style="display:block;"
to the images help at all?

terrybarnes

4:22 pm on Dec 23, 2007 (gmt 0)

10+ Year Member



Many thanks - that has done the trick.

penders

7:12 pm on Dec 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



...in IE6 it seems to add a 4 pixel space below the image.

...probably because IMG's are by default inline elements and sit on the baseline of the surrounding (imaginary) text. The 4px is therefore the gap allowed for any descenders. Whether this effects other browsers may be to do with what DOCTYPE you are using.