Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

want to make it dynamic.... but how?

praneethpraneeth Posts: 21Member
hello ppl,

I am new to java scripr and need some help with this
preload images script.

The problem is that I use this script for loading
many pics on different html pages. So, I keep
pasting it in each page....... now this is redundent stuff,

So i was hoping to make it in to a single .js file and
send the images as parameters from with in the page.

But as i have problems with arrays i couldnt.
So can anyone solve my problem, make the script
in to a dynamic one which accepts the images as
parameters.

Here is the part of the script..









"../4.jpg",
"../5.jpg",
"../6.jpg");


function transfer(param) {
location.href = "mainboard.html"; // URL of second page goes here **
}

function done() {
if (vers < 1.1)
transfer();
else
commence_loading();
}

function commence_loading() {
for (g=0;g= 1.1) {
blue = new Image();
blue.src = "../../images/scroll/blue.gif";
black = new Image();
black.src = "../../images/scroll/white.gif";
}

var loaded = new initArray(0);
for (h=0;h


Comments

  • WeirdofreakWeirdofreak Posts: 439Member
    I didn't bother to read all of that, so this may not work, depending on what exactly it does. What I'm putting will only preload the images, if you want to do anything else, you'll have to modify it. I'm also not entirely sure if it'll work, full stop. I'm not really an expert at calling javascripts, as I hardly ever need to. But here goes:

    Basically, you want to create a function in the included file, that accepts one parameter- the image to preload. This will preload a single image. Then, set up a for loop that calls it with each image you want preloaded.
  • lillulillu Posts: 308Member
    Hi,

    This is a script from js-examples. It preloads a set of images, displays one, then you can click to display the rest one by one.

    HTH,

    Lillu









    #photos {
    position:absolute;
    left:245px;
    top:311px;
    width:50;
    height:50;
    z-index:5;
    background-color: #FFFFFF;
    layer-background-color: #FFFFFF;
    border: 1px none #000000;
    }







    Image Alt Text






    : hello ppl,
    :
    : I am new to java scripr and need some help with this
    : preload images script.
    :
    : The problem is that I use this script for loading
    : many pics on different html pages. So, I keep
    : pasting it in each page....... now this is redundent stuff,
    :
    : So i was hoping to make it in to a single .js file and
    : send the images as parameters from with in the page.
    :
    : But as i have problems with arrays i couldnt.
    : So can anyone solve my problem, make the script
    : in to a dynamic one which accepts the images as
    : parameters.
    :
    : Here is the part of the script..
    :
    :
    :
    :
    :
    :
    :
    :
    :
    : "../4.jpg",
    : "../5.jpg",
    : "../6.jpg");
    :
    :
    : function transfer(param) {
    : location.href = "mainboard.html"; // URL of second page goes here **
    : }
    :
    : function done() {
    : if (vers < 1.1)
    : transfer();
    : else
    : commence_loading();
    : }
    :
    : function commence_loading() {
    : for (g=0;g= 1.1) {
    : blue = new Image();
    : blue.src = "../../images/scroll/blue.gif";
    : black = new Image();
    : black.src = "../../images/scroll/white.gif";
    : }
    :
    : var loaded = new initArray(0);
    : for (h=0;h
    :
    :
    :

Sign In or Register to comment.