Forum Moderators: open

Message Too Old, No Replies

Preloader not preloading !

Help appreciated

         

smokeydaze

12:52 pm on Nov 16, 2008 (gmt 0)

10+ Year Member



Hey Guys !

I'm making my first website at the moment and just made it live which was exciting ! :O

My only problem is that the rollover images aren't preloading, you have to hold the mouse over the image for a second or two before it pops up.

Here is the code from dreamweaver for one of the images:

<a href="tickets.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image8','','../Images/t1.jpg',1)"><img src="../Images/t.jpg" name="Image8" width="51" height="29" border="0" id="Image8" />

Any help greatly appreciated.
Thanks

essiw

1:21 pm on Nov 16, 2008 (gmt 0)

10+ Year Member



you use xhtml with onmouseover? why not make it with css? i thought xhtml with onmouseover is not even valid and where is your end </a> tag?.
but to answer your question i think this might work:
<script langluage="JavaScript">
Image8= new Image
Image8.src = "example.jpg"
Image9= new Image
Image9.src = "example2.gif"
</script>

however i never used it...

smokeydaze

1:28 pm on Nov 16, 2008 (gmt 0)

10+ Year Member



Different example..

<a href="Pages/members.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image19','','Images/v2.jpg',1)"><img src="Images/vip.jpg" name="Image19" width="118" height="110" border="0" id="Image19" /></a>

It works, it just doesn't preload the image.

essiw

2:56 pm on Nov 16, 2008 (gmt 0)

10+ Year Member



have you even read what i said?
<script langluage="JavaScript">
Image8= new Image
Image8.src = "example.jpg"
Image9= new Image
Image9.src = "example2.gif"
</script>
that should preload the images

tedster

8:27 pm on Nov 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've regularly used the kind of pre-load script that essiw proposes. It works pretty well.

Browsers tend not to load images until they need them for display. Even css hover behaviors (in contrast to onmouseover javascript) do not preload the new background image in all browsers.

smokeydaze

10:14 pm on Nov 16, 2008 (gmt 0)

10+ Year Member



That didnt really do anything. Do I just copy and past the text into dreamweaver code and replace jpg extensions?

essiw

2:12 pm on Nov 17, 2008 (gmt 0)

10+ Year Member



i never used it, i use css hover, and put the background image one time extra in it to preload it.

but i think you need to change Image8 and Image9 to the "name" attribute in your code, and you need to change example.jpg in the pictures you use

tedster

7:25 pm on Nov 17, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do I just copy and past the text into dreamweaver code and replace jpg extensions?

Paste it into the very bottom of your source code - right before the </body> tag.

All that really matters is preloading the .jpg, .gif or .png file into the browser cache. I suggest you avoid using the same names in your preload script as your Dreamweaver code uses in the mouseover script. Just pick some name that will keep you from tangling up the variables. You could name the variable "Fred01" if you wanted to.

<script langluage="JavaScript">
Fred01= new Image
Fred01.src = "example.jpg"
Fred02= new Image
Fred02.src = "example2.gif"
Fred03= new Image
Fred03.src = "example2.png"
</script>