PROGRAMMING/JavaScript

javascript 이미지 로딩 체크하는 방법은???

OJR 2009. 5. 13. 19:25

[이미지로딩 체크]

// allImagesLoaded()
        // Checks if all the images are loaded in the document
        // It Does this by looping through all the images and checks the attribute .complete
        // If .complete is false then we set the return variable to 0
        function allImagesLoaded() {
       
                // return variable
                var imagesloaded = 1;
       
                // All images are saved in an array called document.images. Very usefull
                var images = document.images;
                // Loop through all the images
                for (var i = 0;i<images.length;i++)
                {
                        // If the image isnt loaded we set the return varible to 0
                        if(images[i].complete == false) {
                                imagesloaded = 0;
                        }
                }
       
                // This will return 0 if one or more images are not loaded and 1 if all images are loaded.
                return imagesloaded;
        }

http://www.webscriptexpert.com/Javascript/check%20if%20all%20the%20images%20have%20been%20loaded/

Javascript: Check an image is Loaded or Not :

http://www.sajithmr.com/javascript-check-an-image-is-loaded-or-not/

 

Javascript: Check an image is Loaded or Not

How can we check whether an image is loaded fully or partially using javascript. It is possible See the Example Below. function IsImageOk(img) { // During the onload event, IE correctly identifies any images that // weren’t downloaded as not complete....

www.sajithmr.com

Javascript image reload

http://www.haneng.com/asp-forum/Javascript-image-reload_8640.html

function checkImgLoaded()
{
//  var imgLoaded = 1;
  var images = document.images;
  for(var i=0;i<images.length;i++){
    if(images[i].complete==false){
      imgLoaded = 0;
      images[i].src = images[i].src.split("?")[0]+"?"+Math.floor(Math.random()*1000);
    }
  }
//  return imgLoaded;
}
반응형

'PROGRAMMING > JavaScript' 카테고리의 다른 글

javascript blur  (0) 2009.09.14
imagecrop  (0) 2009.06.24
Javascript & CSS 객체 제어 프로퍼티 모델  (0) 2009.05.08
개체 Top, Left 구하기  (0) 2009.04.27
ScriptAculoUs  (0) 2008.11.19