Anybody see why this is not working!

M

Mr.G (@¿@)

Hi, I cliped this and mofified it to be used in a mouse_over to change
the background of text. This is supposed to pre-load the image on
mouse over but it don't!

<script language="Javascript">

function ImgPreLoad()
{
var my_images_array = new Array ('ltrhome.jpg', 'ltrabout',
ltrphoto.jpg', 'ltrmap.jpg', 'ltreq.jpg', 'ltcont.jpg');
LoadmUp (my_images);

}

function LoadmUp (my_images_array)
{
for (loop = 0; loop < my_images_array.length; loop++)
{
var one_image = new Image();
one_image.src = my_images_array[loop];
}
}

</script>
 
E

Evertjan.

Mr.G (@¿@) wrote on 09 aug 2007 in comp.lang.javascript:
Hi, I cliped this and mofified it to be used in a mouse_over to change
the background of text. This is supposed to pre-load the image on
mouse over but it don't!

<script language="Javascript">

You cliped [?] from last century, nowadays use:
function ImgPreLoad()
{
var my_images_array = new Array ('ltrhome.jpg', 'ltrabout',
ltrphoto.jpg', 'ltrmap.jpg', 'ltreq.jpg', 'ltcont.jpg');

ltrabout? that an image name?

You do not need a function to decalre an array.
LoadmUp (my_images);

Unknown parameter my_images
}

function LoadmUp (my_images_array)

Never reuse a variable name a a parameter, You will make mistakes.

Now my_images_array is not an array but ponts to the undeclared variable
named my_images. That should give an error!
{
for (loop = 0; loop < my_images_array.length; loop++)

(var loop = ....

my_images_array.length: undeclared variables have no length.
{
var one_image = new Image();
one_image.src = my_images_array[loop];

not an array.


You do not need a function for preloading.
</script>

The reason you get no error could be
that you do not call ImgPreLoad().

===========================================

Try:

<script type='text/javascript'>
var oneImage;
var myImagesArray = ['ltrhome.jpg','ltrabout.gif','ltrphoto.jpg'];
for (var i = 0; i < myImagesArray.length; i++) {
oneImage = new Image();
oneImage.src = myImagesArray;
};
</script>
 
M

Mr.G (@¿@)

Mr.G (@¿@) wrote on 09 aug 2007 in comp.lang.javascript:
Hi, I cliped this and mofified it to be used in a mouse_over to change
the background of text. This is supposed to pre-load the image on
mouse over but it don't!
<script language="Javascript">

You cliped [?] from last century, nowadays use:
function ImgPreLoad()
{
var my_images_array = new Array ('ltrhome.jpg', 'ltrabout',
ltrphoto.jpg', 'ltrmap.jpg', 'ltreq.jpg', 'ltcont.jpg');

ltrabout? that an image name?

You do not need a function to decalre an array.
LoadmUp (my_images);

Unknown parameter my_images


function LoadmUp (my_images_array)

Never reuse a variable name a a parameter, You will make mistakes.

Now my_images_array is not an array but ponts to the undeclared variable
named my_images. That should give an error!
{
for (loop = 0; loop < my_images_array.length; loop++)

(var loop = ....

my_images_array.length: undeclared variables have no length.
{
var one_image = new Image();
one_image.src = my_images_array[loop];

not an array.

You do not need a function for preloading.


</script>

The reason you get no error could be
that you do not call ImgPreLoad().

===========================================

Try:

<script type='text/javascript'>
var oneImage;
var myImagesArray = ['ltrhome.jpg','ltrabout.gif','ltrphoto.jpg'];
for (var i = 0; i < myImagesArray.length; i++) {
oneImage = new Image();
oneImage.src = myImagesArray;};

</script>


I need to try that thanks, goodm
 
M

Mr.G (@¿@)

Mr.G (@¿@) wrote on 09 aug 2007 in comp.lang.javascript:
Hi, I cliped this and mofified it to be used in a mouse_over to change
the background of text. This is supposed to pre-load the image on
mouse over but it don't!
<script language="Javascript">

You cliped [?] from last century, nowadays use:
function ImgPreLoad()
{
var my_images_array = new Array ('ltrhome.jpg', 'ltrabout',
ltrphoto.jpg', 'ltrmap.jpg', 'ltreq.jpg', 'ltcont.jpg');

ltrabout? that an image name?

You do not need a function to decalre an array.
LoadmUp (my_images);

Unknown parameter my_images


function LoadmUp (my_images_array)

Never reuse a variable name a a parameter, You will make mistakes.

Now my_images_array is not an array but ponts to the undeclared variable
named my_images. That should give an error!
{
for (loop = 0; loop < my_images_array.length; loop++)

(var loop = ....

my_images_array.length: undeclared variables have no length.
{
var one_image = new Image();
one_image.src = my_images_array[loop];

not an array.

You do not need a function for preloading.


</script>

The reason you get no error could be
that you do not call ImgPreLoad().

===========================================

Try:

<script type='text/javascript'>
var oneImage;
var myImagesArray = ['ltrhome.jpg','ltrabout.gif','ltrphoto.jpg'];
for (var i = 0; i < myImagesArray.length; i++) {
oneImage = new Image();
oneImage.src = myImagesArray;};

</script>


wow that worked really well!!!
Like I said I nipped it from some tutorial on progrming in javascrip
but it didn't work. They loaded only after the mouse was over the
image. But now thanks to you they are changing as soon as the mouse is
over. thanks again!
 

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
474,434
Messages
2,571,689
Members
48,796
Latest member
Greg L.

Latest Threads

Top