JavaScript and client side scripting.
Moderator: General Moderators
-
hawleyjr
- BeerMod
- Posts: 2170
- Joined: Tue Jan 13, 2004 4:58 pm
- Location: Jax FL & Spokane WA USA
Post
by hawleyjr »
Is there a way using JavaScript to telll if an image is 100% loaded?
Code: Select all
<script language="javascript">
var imgObj = new Image();
var imgObjNext = new Image();
var cssCheckCounter = 0;
function ChangeImage(){
imgObj.src = img_url_from_server;//url is from an xhtml request
updateCSS();
}
function updateCSS(){
if(cssCheckCounter > 5 || imgObj == 'is loaded'){ //ADD IMAGE CHECKING HERE.....
//RUN CODE IF IMAGE IS 100% LOADED
...
..
.
cssCheckCounter = 0;
}
}else{
cssCheckCounter++;
setTimeout("updateCSS()",1000);
}
}
</script>
Last edited by
hawleyjr on Sun Sep 11, 2005 11:24 am, edited 1 time in total.
-
feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Post
by feyd »
set the onload event for the image
