SearchSearch   

Anybody see why this is not working!

 
   Webmaster Forums (Home) -> Javascript RSS
Next:  retrieving the user input from the onbeforeunload..  
Author Message
"Mr.G

External


Since: Aug 09, 2007
Posts: 3



(Msg. 1) Posted: Thu Aug 09, 2007 9:19 am
Post subject: Anybody see why this is not working!
Archived from groups: comp>lang>javascript (more info?)

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>
Back to top
Evertjan.

External


Since: Sep 30, 2005
Posts: 2391



(Msg. 2) Posted: Thu Aug 09, 2007 5:49 pm
Post subject: Re: Anybody see why this is not working!
Archived from groups: per prev. post (more info?)

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:
<script type='text/javascript'>

> 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[i];
};
</script>



--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Back to top
"Mr.G

External


Since: Aug 09, 2007
Posts: 3



(Msg. 3) Posted: Wed Aug 15, 2007 11:30 am
Post subject: Re: Anybody see why this is not working!
Archived from groups: per prev. post (more info?)

On Aug 9, 10:49 am, "Evertjan." <exjxw.hannivo....DeleteThis@interxnl.net> wrote:
> 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:
> <script type='text/javascript'>
>
> > 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[i];};
>
> </script>
>
> --
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)

I need to try that thanks, goodm
Back to top
"Mr.G

External


Since: Aug 09, 2007
Posts: 3



(Msg. 4) Posted: Wed Aug 15, 2007 11:37 am
Post subject: Re: Anybody see why this is not working!
Archived from groups: per prev. post (more info?)

On Aug 9, 10:49 am, "Evertjan." <exjxw.hannivo....DeleteThis@interxnl.net> wrote:
> 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:
> <script type='text/javascript'>
>
> > 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[i];};
>
> </script>
>
> --
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)

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!
Back to top
Display posts from previous:   
       Webmaster Forums (Home) -> Javascript
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum