<html> <title> Image Preload </title> <body> <script> // Juez Browser var Browser = nuevo Objeto (); browser.useragent = window.navigator.useragent.tolowercase (); browser.ie =/msie/.test (browser.useragent); browser.moz =/gecko/.test (browser.useragent); // juzga si la carga está completa la imagen de la función (url, imgid, válvula) {URL = URL = URL; var img = nueva imagen (); if (browser.ie) {img.onreadyStateChange = function () {if (img.readyState == "completo" || img.readyState == "cargado") {devolución de llamada (img, imgid); }}} else if (browser.moz) {img.onload = function () {if (img.complete == true) {callback (img, imgid); }}}} // Si se produce una excepción debido a la red o la imagen, la imagen se muestra img.onerror = function () {img.src = 'http: //www.baidu.com/img/baidu_logo.gif'} img.src = val;} // La función de la imagen de la imagen checkImg (obj, imgid) {document.getElementById (imgid) .src = obj.src;} // Inicializar la imagen que se mostrará y especifique la ventana de ubicación de visualización.onload = function () { Imagess ("http://hiphotos.baidu.com/lovebyakuya/pic/item/01cf20088f9506f063d98653.jpg", "img1", checkimg); Imagess ("http://hiphotos.baidu.com/lovebyakuya/pic/item/7b7b19c70d62f4fdd0006050.jpg", "img2", checkimg); Imagess ("http://hiphotos.baidu.com/joanne728/pic/item/892557641806d20eaa184c71.jpg", "img3", checkimg); Imagess ("http://www.neocha.com/-/res/camilla/20071204181216078845_h.jpg", "img4", checkImg); Imagess ("http://wwww.neocha.com/-/res/camilla/20071204181216d0788845_h.", "Img5", chechimg);} </script> /> <img id = "img3" src = "loading.gif" /> <img id = "img4" src = "loading.gif" /> <img id = "img5" src = "loading.gif" /> < /body> < /html>