The method for loading images in javascript sequence and loading in javascript Sequence
This example describes how to load images sequentially in javascript. Share it with you for your reference. The details are as follows:
Javascript listens to whether an image has been loaded. If loading is complete and then loads the next image, it is not a one-time load from the server to reduce the load on the server,
Available: for example, to create an application similar to google Maps, you can load a thumbnail one by one.
Function Load_pic (arr) {this. loop_f = function (I, o_file, len, f, obj) {if (I <len-1) {I = I + 1; f (I, o_file, len, obj) ;}}; this. creat_pic = function (I, o_file, len, obj) {var f = arguments. callee, doc = document, image = doc. createElement ("img"); image. src = o_file [I]; I <len? Doc. getElementsByTagName ("body") [0]. appendChild (image): ''; if (navigator. userAgent. indexOf ("MSIE")> 0) {if ($. browser. version = 6.0 | $. browser. version = 9.0) {// Like IE9 and IE6, Microsoft is really a weird image. onreadystatechange = function () {if (image. readyState = "complete") {obj. loop_f (I, o_file, len, f, obj) ;}}}else {ie7imagetime = window. setInterval (function () {var rs = image. readyState; if (rs = "complete") {window. clea RInterval (ie7imagetime); obj. loop_f (I, o_file, len, f, obj) ;}else {return ;}, 200) ;}} else {image. onload = function () {if (image. complete = true) {obj. loop_f (I, o_file, len, f, obj) ;}}}; if (arr. constructor = Array) {var len = arr. length, I = 0; I <len? This. creat_pic (I, arr, len, this): '';}}// call the new Load_pic method (['HTTP: // callback); // call jquery to determine the browser
I hope this article will help you design javascript programs.