How to get rid of the delay that happens when you use multiple images with ‘onmouseover’? Preload all the images.
You can supply one image url as an argument to this function, or an array of image urls.
Source code for webtoolkit.imagepreload.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
/**
*
* Image preload
* http://www.webtoolkit.info/
*
**/
function ImagePreload() {
if (typeof(arguments) != 'undefined') {
for (i=0; i<arguments.length; i++ ) {
if (typeof(arguments[i]) == "object") {
for (k=0; k<arguments[i].length; k++) {
var oImage = new Image;
oImage.src = arguments[i][k];
}
}
if (typeof(arguments[i]) == "string") {
var oImage = new Image;
oImage.src = arguments[i];
}
}
}
}
|