Announcement

Collapse
No announcement yet.

Preloading Javascript Images

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Preloading Javascript Images

    I am using a simple image swap routine in a fragment using:

    HTML Code:
    <img src="imageSwap1.jpg" name="swapImage" id="swapImage" ...>
    <a ... onmouseover="document.swapImage.src='imageSwap1.jpg'">
    <a ... onmouseover="document.swapImage.src='imageSwap2.jpg'">
    ... etc
    What is the best way to preload the images imageSwap2.jpg, imageSwap3.jpg etc to prevent lag on the mouseover?

    Tried using

    HTML Code:
    Image2= new Image(200,200)
    Image2.src = "imageSwap2.jpg"
    .. etc
    but to no apparent effect


    Bikster
    SellerDeck Designs and Responsive Themes

    #2
    what sort of lag are you noticing?
    I've just used (in a site I'm working on)

    Code:
    <A href="xxxx.html" OnMouseOver = "document.images.img2.src= 'img1.jpg'" 
    OnMouseOut ="document.images.img2.src='img2.jpg'" >
    
    <IMG SRC = "img2.jpg" NAME = "img2" Border = "0" >
    
    </A>
    and I don't notice any lag
    Tracey

    Comment


      #3
      why dont you use quit using crappy javascript and use beautiful css offsets instead?



      like these:
      http://exploding-boy.com/images/cssmenus/menus.html

      HTML Code:
          #tabs {
            float:left;
            width:100%;
            background:#BBD9EE;
            font-size:93%;
            line-height:normal;
            }
          #tabs ul {
      	  margin:0;
      	  padding:10px 10px 0 50px;
      	  list-style:none;
            }
          #tabs li {
            display:inline;
            margin:0;
            padding:0;
            }
          #tabs a {
            float:left;
            background:url("tableft.gif") no-repeat left top;
            margin:0;
            padding:0 0 0 4px;
            text-decoration:none;
            }
          #tabs a span {
            float:left;
            display:block;
            background:url("tabright.gif") no-repeat right top;
            padding:5px 15px 4px 6px;
            color:#666;
            }
          /* Commented Backslash Hack hides rule from IE5-Mac \*/
          #tabs a span {float:none;}
          /* End IE5-Mac hack */
          #tabs a:hover span {
            color:#FF9834;
            }
          #tabs a:hover {
            background-position:0% -42px;
            }
          #tabs a:hover span {
            background-position:100% -42px;
            }

      Comment


        #4
        Originally posted by TraceyHand View Post
        what sort of lag are you noticing?
        Actually - looking again it hardly noticeable - probably me wanting psychic pre-emptive loading


        Bikster
        SellerDeck Designs and Responsive Themes

        Comment


          #5
          Originally posted by gabrielcrowe View Post
          use beautiful css offsets instead?
          This is a temp stop gap - I have a css version on the boards at the moment which whacks it -90 billion pixels off screen and drags it back on the a:hover


          Bikster
          SellerDeck Designs and Responsive Themes

          Comment


            #6
            Originally posted by jont View Post
            This is a temp stop gap - I have a css version on the boards at the moment which whacks it -90 billion pixels off screen and drags it back on the a:hover
            that much

            Comment


              #7
              Better safe than sorry matey .. have you seen the size of them new DELL widescreen monitors? They put the Imax to shame


              Bikster
              SellerDeck Designs and Responsive Themes

              Comment

              Working...
              X