bol
10-11-2004, 09:33 PM
I have included an expand function in my page, which makes use of the css 'clip' attribute to reveal the title bar image. The script was kindly donated to me by fang I seem to remember.... not very good with names.
It runs fine on local testing but when online the effect is spoiled by a timing glitch.
the script is here, I'll run through what happens at the bottom.
<script type="text/javascript">
<!--
var Imgwidth=-1;
var timeoutID=null;
function makeTheImageWipeAcross() {
Imgwidth++;
document.getElementById('onTop').style.clip="rect(0px, 678px, "+Imgwidth+"px, 0px)";
if(Imgwidth<=147) {
timeoutID=setTimeout("makeTheImageWipeAcross()", 1);
}
else {
clearTimeout(timeoutID);
}
}
//-->
</script>
html....
<body onload="makeTheImageWipeAcross();">
<div id=topImage><img id="onTop" src="images/aboutEn.jpg" height="147" width="678" name="image" align="right">
in testing the image 'wipes' across the layer background, giving the appearance of animation. Online however the image appears fully loaded before the function begins. Obviously this is a timing error caused by the time it takes for the rest of the page to download. What would be the best way of solving this problem so that the image starts off hidden and only appears once it has been downloaded and the JS function is ready to run. I guess what I'm really not sure about is the order in which the browser loads up the script.
Sorry if this explanation is a bit garbled. Thanks in advance.
It runs fine on local testing but when online the effect is spoiled by a timing glitch.
the script is here, I'll run through what happens at the bottom.
<script type="text/javascript">
<!--
var Imgwidth=-1;
var timeoutID=null;
function makeTheImageWipeAcross() {
Imgwidth++;
document.getElementById('onTop').style.clip="rect(0px, 678px, "+Imgwidth+"px, 0px)";
if(Imgwidth<=147) {
timeoutID=setTimeout("makeTheImageWipeAcross()", 1);
}
else {
clearTimeout(timeoutID);
}
}
//-->
</script>
html....
<body onload="makeTheImageWipeAcross();">
<div id=topImage><img id="onTop" src="images/aboutEn.jpg" height="147" width="678" name="image" align="right">
in testing the image 'wipes' across the layer background, giving the appearance of animation. Online however the image appears fully loaded before the function begins. Obviously this is a timing error caused by the time it takes for the rest of the page to download. What would be the best way of solving this problem so that the image starts off hidden and only appears once it has been downloaded and the JS function is ready to run. I guess what I'm really not sure about is the order in which the browser loads up the script.
Sorry if this explanation is a bit garbled. Thanks in advance.