javascript - Pre-loaded images not displaying in Chrome -
i pre-loading images , using them in lightbox. problem have although images loading, aren't being displayed browser.
this issue specific chrome. has persisted through chrome 8 - 10, , i've been trying on , off fix time , have got nowhere.
i have read these similar questions,
chrome not displaying images though assets being delivered browser
2 minor crossbrowser css issues. background images not displaying in google chrome?
javascript preloaded images getting reloaded
which detail similar behaviour in chrome mac. whereas happening in windows.
- all other browsers seem fine.
- if have firefox , chrome open, load page in firefox, , in chrome, images appear.
- once have manually loaded images, using webkit webdev toolbar thingy, show up
- all links images , such fine , working
- clearing chrome doesn't seem make difference (cache, history, etc)
if has ideas fantastically helpfull, i'm literally out of options here.
ps, apologies if there late replies, i'm off on holiday week tomorrow! :d
update here javascript function preloading images.
var preloaded = new array(); function preload_images() { (var = 0; < arguments.length; i++){ document.write('<'); document.write('img src=\"'+arguments[i]+'\" style=\"display:none;\">'); }; };
update
i'm still having issues this, , i've removed whole preloading images function. perhaps delivering style sheet via document.write()
isn't best way?
chrome might not preloading them it's writing dom no display, might intelligent enough realise doesn't need rendered. try instead:
var preloaded = new array(); function preload_images(){ (var x = 0; x < preload_images.arguments.length; x++) { preloaded[x] = new image(); preloaded[x].src = preload_images.arguments[x]; } }
the javascript image object has lot of useful functions might find useful:
http://www.javascriptkit.com/jsref/image.shtml
onabort()
code executed when user aborts downloading of image.
onerror()
code executed when error occurs loading of image (ie: not found). example(s)
onload()
code executed when image , downloads.
and have complete
property true/false tells if image has (pre)loaded.
Comments
Post a Comment