Is it possible to catch all images while the page is loading, before onload is triggered?
I would like to load all images after onload event with some ajax icon on background.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can execute arbitrary Javascript code in the page, without using the
onloadevent: (see http://bytes.com/topic/javascript/answers/147703-there-any-call-before-body-onload)(Alert order: 0, 1, 2.)
Now, at the point of
alert(1), you can usedocument.getElementsByTagName(), and select yourimgtags to do whatever you want with them. It’s even possible to create a script that postpones loading of images until they should be in the visible scroll area. This is useful for huge lists with images.However, a more easy solution would be to use CSS and apply a background-image on each
imgelement.