way to stop or pause onLoad event?

N

needusenethelp

I have a preloader that is called from the onLoad. This is great, but
if there is a slow connection the preloader may continue to run and
other scripts cannot run -- in this case the mouseovers. It would
make more sense for the large pictures to take a longer time to open
after the mouseover rather than the mouseovers not work at all while
the preloader continues. Does anyone know if there is a way to pause
the preloader? Perhaps a global variable that the preloader keeps
checking between loads and have the mouseovers change this variable
when they are finished or something better?

Thanks for any help!
 
E

Erwin Moller

(e-mail address removed) schreef:
I have a preloader that is called from the onLoad. This is great, but
if there is a slow connection the preloader may continue to run and
other scripts cannot run -- in this case the mouseovers.

Hi,

I don't think the above is correct.
If this preload function only assigns src to images, it will finish very
quickly.
You can test this by making it do an alert after the last preload
command in your function.

The source of the images will be fetched in the background by the
browser, and your javascript just runs fine then.

You problem is propably that it takes some time for the source of the
images to arrive.
This is an important distiction.


It would
make more sense for the large pictures to take a longer time to open
after the mouseover rather than the mouseovers not work at all while
the preloader continues. Does anyone know if there is a way to pause
the preloader?

The preloader is NOT running anymore I think.
Please check this by adding the abovementioned alert in the function.

Perhaps a global variable that the preloader keeps
checking between loads and have the mouseovers change this variable
when they are finished or something better?

Thanks for any help!

What you need is some priorities in the fetching of the images.

You want to fecth small images img1, img20, and img50 first, then big
images img 102, etc.

A possible way to implement this is using the load event of an image:

var someImg = new Image();
someImg.src = 'http://www.example.com/images/myImg.png';
someImg.onload = nextPlease();

function nextPlease()
{
// go fetch next image
}

That way you can fetch the images in a certain order.

--> WARNING: I expect the overall loadingtime of the images will be MUCH
longer if you fetch them one by one because parallel fetching is faster
than sequencial. (You browser can fetch many images at the same time,
possibly using all available bandwith optimally)

So if you take this route I advise you to fetch all images needed for
the userinterface first (and not sequencial, but parallel), and when
they are all in start fetching the biggies.

Hope this helps.

Regards,
Erwin Moller

--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top