www.webdeveloper.com
Results 1 to 6 of 6

Thread: [RESOLVED] Preload images to appear on mouse over

  1. #1
    Join Date
    Jul 2006
    Posts
    373

    resolved [RESOLVED] Preload images to appear on mouse over

    Hi,

    Im using this code for rolling images onmouseover

    function roll(img_name, img_src)
    {
    document[img_name].src = img_src;
    }


    and it works very nice except for one thing, the image that is supposed to appear onmouseover doesnt show up the very first time immediately as you roll over but with some seconds delay because they dont load along with the page, but only after you call them by rolling over, so i need an additional code for pre-loading these image so they appear when they should.

    I tried with this code for doing that but it doesnt work

    Code:
    <script>
    function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }
    </script>
    
    </head> 
    
    <body onLoad="MM_preloadImages('roll3.gif', 'roll2.gif', 'roll4.gif')">
    so i hope you can show me a code that can be used in conjunction with the first i posted.

    thank you.

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    At least 98% of internet users' DNA is identical to that of chimpanzees

  3. #3
    Join Date
    Jul 2006
    Posts
    373
    Very interesting stuff. However, i already have made a lot of images throughout my page and im running out of time to finish it, so i need quite a faster solution than modifying all of them to that system you suggest. Thank you anyway.

  4. #4
    Join Date
    Jul 2006
    Posts
    373
    Any alternative solution please?

  5. #5
    Join Date
    Jan 2009
    Posts
    17

  6. #6
    Join Date
    Jul 2006
    Posts
    373
    Actually the preload code i posted first works, its just that i had the image paths wrong haha. Sorry and thanks all of you.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles