I have a PHP page displaying a bulletin, and an image is embedded in the text. I added the simplified code here. Problem is that when I attempt to change the size of the image, DOM cannot reference the image. In the actual file, if I freshly load the page, the image cannot be referenced, but if I navigate back to it (using a date selector), all of the sudden the Javascript resizing works just fine. Just does not work the first time the image is loaded.
function resizeImg () {
var w=document.getElementById("textImg").width;
var h=document.getElementById("textImg").height;
alert(h+" "+w);
if (w>300 || h>300) {
if (w>300) {
var factor=((300/w));
} else {
if (h>300) {
var factor=((300/h));
}
}
w*=factor;w=Math.round(w);
h*=factor;h=Math.round(h);
document.getElementById("textImg").style.width=w+"px";
document.getElementById("textImg").style.height=h+"px";
}
}//end FUNCTION
HEADER:
<?php
$pic="20130213.gif";
$blText="Yes, you heard right. Thats all we are going to have for dinner. Why? because cream of corn is good when you put sugar in it, with some pepper and butter. So, quit your complaining and eat the slop.";
?>
HTML:
<body>
<div id="bullText" class="tBorder">
<div class="tBorder" id="bullTextArea">
<?php
$file="../../Admin/aPages/upload/".$pic;
echo "<img id='textImg' class='textImage' src='".$file."' alt='no image' />";
echo $blText
?>
</div>
</div><!--BULL TEXT DIV-->
<?php
echo "<script>resizeImg ()</script>";
?>
</body>