preloading images...

Discussion in 'Javascript' started by riki, Feb 24, 2004.

  1. riki

    riki Guest

    hello,
    i found this script on the internet (i simplified it a little) and i have
    two questions:

    <script language=javascript>
    var preloadimages=new
    Array("pic1.jpg","pic2.jpg","pic3.jpg","pic4.jpg","pic5.jpg"...etc);
    var theimages=new Array();

    for (p=0;p<preloadimages.length;p++){
    theimages[p]=new Image();
    theimages[p].src="/html/images/"+preloadimages[p];}
    </script>

    Q1: i want to use preloading for images that opens in popUp window. when i
    click on the little thumb, larger pic opens in the popUp and i would like to
    preload this larger pic. is it posible or does it use only for rollover
    pics, i mean pics that open on the same page (not in popUp)?

    Q2: if i previously used link on main page i.e.
    window.open('/html/images/pic1.jpg','','properties'), should i change that
    whit this one window.open('/html/images/theimages[p].src','','properties')
    or would it work like it was? i mean should i change names of the pics
    "pic1.jpg","pic2.jpg","pic3.jpg","pic4.jpg","pic5.jpg"...etc with preloaded
    array "theimages[0].src","theimages[1].src","theimages[2].src",...etc.
    thank you!
     
    riki, Feb 24, 2004
    #1
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.