/    Sign up×
Community /Pin to ProfileBookmark

Need help with image loading events

Hi,
I have this script (taken from [url]http://www.wait-till-i.com/2007/07/10/return-of-the-http-overhead-delay-this-time-without-a-server-side-component/[/url]).

[code]delayHTTPoverhead = function() {
var parentID = ”;
var avtClass = ”;
function ri() {
var img = parentID !== ” ? document.getElementById(parentID).getElementsByTagName(‘img’) : document.getElementsByTagName(‘img’);
var rep = /.*#/;
for (var i = 0; img[i]; i++) {
var src = img[i].src;
if (src.indexOf(‘#’) != -1 && img[i].className.indexOf(avtClass) !== -1) {
img[i].src = src.replace(rep, ”);
};
};
}
var o = window.onload;
if (typeof window.onload != ‘function’) {
window.onload = ri;
} else {
window.onload = function() {
if (o) {
o();
};
ri();
};
};
} ();[/code]

That work’s with image tags like this ones:

[code]<img src=”lowres1.jpg#highres1.jpg” />
<img src=”lowres2.jpg#highres2.jpg” />[/code]

I need help with adding a simple feature to this script..
I want the script to replace the images [b]one-by-one[/b]. So it replaces the source of the first image, waits till the “highres” image loads and then moves to the next image and so on…
At the very end, when all the highres images are loaded i also need to execute another function, but this should be easy i guess…

I’d really appreciate any help with this!
Thanks,
Mark.

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @karrudo spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...