Page is a not externally linkable
Fotiman - 1:01 pm on Jul 9, 2010 (gmt 0)
The script you have now can be modified to preload the new images like so:
for (id in imgSwap) {
if (imgSwap.hasOwnProperty(id)) {
el = document.getElementById(id);
if (el) {
// Attach event handlers
el.onmouseover = function (el, src) {
return function () {
el.src = src;
};
}(el, imgSwap[id].newImg);
el.onmouseout = function (el, src) {
return function () {
el.src = src;
};
}(el, imgSwap[id].oldImg);
// Preload images
var preloadImg = new Image();
preloadImg.src = imgSwap[id].newImg;
}
}
}