Results 1 to 12 of 12

Thread: Preload Image for MouseOver

  1. #1

    Thread Starter
    Addicted Member TheGoldenShogun's Avatar
    Join Date
    Mar 2001
    Location
    VA/MD... anywhere around the beltway
    Posts
    236

    Cool Preload Image for MouseOver

    I made some pretty cool looking buttons in Photoshop, saved them for web (about 4K) but when I put them on the web, the mouseover didn't work as good as I had anticipated. Here what I have in code.


    <script language='JavaScript'>
    var overOut = false
    function imgSwap(src)
    {

    newName=src.name + "over.gif"

    if (!overOut)
    {
    src.src=orderover.gif
    overOut=true
    }
    else
    {
    src.src=src.name + '.gif'
    overOut=false

    }

    }


    </script>
    <body>
    <a href='http://www.whatever.com'><img src='order.gif' border='0' name='order' onMouseOver='imgSwap(this)' onMouseOut='imgSwap(this)'></a>

    Is there a way to perhaps preload all the images onLoad of the page so that it's not looking for the new image everytime?

    Thanks

  2. #2
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    well yes...

    var ImagesList;
    ImageList = new Array();
    ImageList[0] = new Image(110,25);
    ImageList[0].src = yourPath
    ImageList[1] = new Image(110,25);
    ImageList[1].src = your Path


    and use ImageList[1].src

    something like:

    function imgover(imgname,position){
    imgname.src = ImageList[position].src;
    }
    function imgout(imgname,position){
    imgname.src = ImageList[position].src;
    }

  3. #3

    Thread Starter
    Addicted Member TheGoldenShogun's Avatar
    Join Date
    Mar 2001
    Location
    VA/MD... anywhere around the beltway
    Posts
    236

    Cool

    thanks, that code did make the mouseOver flow better, but still not as good as i had planned. Right now my images are 3.5 K, what's a good size for an image if you're working a mouseover?

  4. #4
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    if it too slow, because your image size!

    do it with layers! it will be faster!!

  5. #5

    Thread Starter
    Addicted Member TheGoldenShogun's Avatar
    Join Date
    Mar 2001
    Location
    VA/MD... anywhere around the beltway
    Posts
    236
    Layers, you mean in Photoshop, I got plenty of layers, just have to cut back on the beveling and embossing things... I got my image size down to 2.1 so it's working better now, just made the image smaller.

  6. #6
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    i meant layer in your html document,

    gimmie a sec to build you an example!!

  7. #7
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    i try it, and it did not had the result i espected,

    it was not working if you pass your mouse over really quick,

    is your page on the web, show me where i'll see if how slow it is!!

  8. #8

    Thread Starter
    Addicted Member TheGoldenShogun's Avatar
    Join Date
    Mar 2001
    Location
    VA/MD... anywhere around the beltway
    Posts
    236
    it's just got the images right now..

    http://www.visualwow.net/David/ROVC/storesam.html

    let me know what you think.


  9. #9
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    really nice,

    i think you problem might be:

    function imgSwap(src, imgNum)
    {

    newName=orderOver[imgNum]

    if (!overOut)
    {
    src.src=newName
    overOut=true
    }
    else
    {
    src.src=src.name + '.gif'
    overOut=false

    }
    }

    this line -----src.src=src.name + '.gif'

    try putting your out images in the array so that you always use the array

    so

    Code:
    <html>
    <head>
    
    </head>
    
    <script language='JavaScript'>
    var overOut = false
    var orderOver = new Array();
    orderOver[0] = "orderOver.gif";
    orderOver[1] = "order.gif";
    orderOver[2] = "photoOver.gif";
    orderOver[3] = "photo.gif";
    
    function imgSwap(src, imgNum)
    {
    
    	newName=orderOver[imgNum]
    
    	if (!overOut)
    	{
    	src.src=newName
    	overOut=true
    	}
    	else
    	{
    	src.src=newName
    	overOut=false
    
    	}
    
    }
    
    
    </script>
    
    <body leftmargin='0' topmargin='0'>
    <!-- Heading/Navigation Button Section -->
    <table cellpadding='0' cellspacing='0' width='750px' height='550px' border='0'>
    <tr><td width='130px' bgcolor='#009966' valign='top'><a href='http://www.msn.com'><img src='order.gif' border='0' name='order' onMouseOver='imgSwap(this, 0)' onMouseOut='imgSwap(this, 1)'></a><br>
    <a href='http://www.msn.com'><img src='photo.gif' border='0' name='photo' onMouseOver='imgSwap(this, 2)' onMouseOut='imgSwap(this, 3)'></a><br>
    </td>
    
    
    <!-- Other Content Section -->
    <td>&nbsp</td></tr>
    </table>
    
    
    </body>
    </html>
    let me know if there a difference,

    btw, your picture look very nice, good job!

    i like your photo button

  10. #10

    Thread Starter
    Addicted Member TheGoldenShogun's Avatar
    Join Date
    Mar 2001
    Location
    VA/MD... anywhere around the beltway
    Posts
    236
    thanks for the feedback, I plugged your code into it and it's working as good as it with this connection I have. By the way, I'm doing this for a local area vet who wants to sell supplied online... do you know what the procedures are for getting credit card information? this is actually my first client (started the business two weeks ago) and I'm just trying to cover all my bases.

    Thanks

  11. #11
    scoutt
    Guest
    Originally posted by TheGoldenShogun
    thanks for the feedback, I plugged your code into it and it's working as good as it with this connection I have. By the way, I'm doing this for a local area vet who wants to sell supplied online... do you know what the procedures are for getting credit card information? this is actually my first client (started the business two weeks ago) and I'm just trying to cover all my bases.

    Thanks
    you would need to setup a merchant account to handle credit cards.

    I can't right off hand remember the best merchants to get, but I can look fo rya a little later.

  12. #12
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width