use:
Copy the codeThe code is as follows:
var loader = new ImageLoader(ClassName,Options);
Creates the object in the form of .
in:
loader: is the JavaScript variable name;
ClassName: String type: is the expression of loader in JavaScript. If you create this object outside of any function, please directly assign the string form of the variable, such as the corresponding loader is "loader"; if it is in a function body, you still assign the string form of the variable, but please use the form of the variable name created.
Options : Object type, the following properties are supported:
Timeout: Integer, optional. The value is 1-100,000 in milliseconds. Non-positive integer representation is not used. This is the maximum loading time of an image. If this parameter is provided, if a certain image cannot be downloaded normally, you can skip to continue downloading another image. Otherwise, you will wait until the image is downloaded.
func � The function called after all images are loaded is usually a function that displays the functions of these images. If this function is not provided, the entire mechanism will become useless. Function-type parameters will be called directly, and String-type parameters will be run as JavaScript statements.
display : String / Object, optional. This is the DOM object that displays the currently loaded image, which should support the innerHTML attribute. When this parameter is provided as String, it will be treated as the id of the DOM object. If the Object type is used, it will be treated as a DOM object directly. There is no effect on other types provided.
Process : String / Object, optional. This is a DOM object that displays the current loading progress in percentages, which should support the innerHTML attribute. When this parameter is provided as String, it will be treated as the id of the DOM object. If the Object type is used, it will be treated as a DOM object directly. There is no effect on other types provided.
See the following example:
Copy the codeThe code is as follows:
//When outside all functions
//function final(){...};
function $(par){
return (par)
}
var MyLoader = new ImageLoader("MyLoader ",{Timeout:1000,func: final,display:"display",process:$("process")});
//When in a function body
function somefunc(){
//...
= new ImageLoader("MyLoader ",{Timeout:1000,func: "alert('fine')",display:"display",process:$("process")});
//...
}
Method definition:
Load(paralist) : Load a series of pictures. The content of the func attribute is automatically called after completion. paralist, can be a collection of some strings (but don't provide an array), separated by , . These strings should be the url of the picture. No parameters can be provided either. The Load method will load the pre-set series of pictures. If it has not been preset, the content of the func attribute is called directly. If func is not provided, there is no effect.
Copy the codeThe code is as follows:
//sample:
("/images/blue/",
"/2006/chinaok/",
"/2006/now/",
"/2006/gongyi/",
"/2006/flash8/",
"/intl/zh-CN_ALL/images/");
//or if pic series is provided.
();
setLoadImages(ArrayImages): Set the series of pictures to be loaded. ArrayImages should be provided in the form of an array, and each element of the array should be the URL of an image. No other types of parameters are accepted. This method does not start loading the image after it is called.
Copy the codeThe code is as follows:
//sample:
(["/images/blue/",
"/2006/chinaok/",
"/2006/now/",
"/2006/gongyi/",
"/2006/flash8/",
"/intl/zh-CN_ALL/images/"])
Previous page123Next pageRead the full text