C
Csaba Gabor
I have an IMG placeholder for what will normally be a tiny (6x7) img.
Sometimes however, I will use a somewhat larger but still small image.
How can I unset the dimensions for the <IMG id=normallyTiny ...>
element I have already specified, rather than using the tortured code
below? Unfortunately, I must set the dimensions at the outset, because
otherwise the placeholder for the 'normallyTiny' image will be too big.
<BODY onload="docLoaded()">
<IMG id=dummyImg onload="reviseImg()" style="visibility:hidden"
src="http://us.i1.yimg.com/us.yimg.com/i/us/pim/f/perc1.gif">
<IMG height=6 width=7 id=normallyTiny>
<SCRIPT type='text/javascript'>
function docLoaded() {
alert('document is loaded: ' + typeof(document.body.onload)); }
function reviseImg() {
alert('dummy image is preloaded');
var dummyImg = document.getElementById('dummyImg');
var img = document.getElementById('normallyTiny');
img.width = dummyImg.width;
img.height = dummyImg.height;
img.src = dummyImg.src; }
</SCRIPT>
</BODY>
Trying delete img.width has no effect and trying img.width=0 or "" or
null merely cause the subsequent image to not show.
Note that the order of the alerts differs between IE6 and FF Deer Park
Alpha.
An unrelated question is: where is the document's onload function
living in Firefox? The code above (see the 'typeof') finds it for IE.
Thanks,
Csaba Gabor from Vienna
Sometimes however, I will use a somewhat larger but still small image.
How can I unset the dimensions for the <IMG id=normallyTiny ...>
element I have already specified, rather than using the tortured code
below? Unfortunately, I must set the dimensions at the outset, because
otherwise the placeholder for the 'normallyTiny' image will be too big.
<BODY onload="docLoaded()">
<IMG id=dummyImg onload="reviseImg()" style="visibility:hidden"
src="http://us.i1.yimg.com/us.yimg.com/i/us/pim/f/perc1.gif">
<IMG height=6 width=7 id=normallyTiny>
<SCRIPT type='text/javascript'>
function docLoaded() {
alert('document is loaded: ' + typeof(document.body.onload)); }
function reviseImg() {
alert('dummy image is preloaded');
var dummyImg = document.getElementById('dummyImg');
var img = document.getElementById('normallyTiny');
img.width = dummyImg.width;
img.height = dummyImg.height;
img.src = dummyImg.src; }
</SCRIPT>
</BODY>
Trying delete img.width has no effect and trying img.width=0 or "" or
null merely cause the subsequent image to not show.
Note that the order of the alerts differs between IE6 and FF Deer Park
Alpha.
An unrelated question is: where is the document's onload function
living in Firefox? The code above (see the 'typeof') finds it for IE.
Thanks,
Csaba Gabor from Vienna