SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Small rollover script

    This little script keeps on giving me an error (Object expected), but I can't figure out why.

    Code:
    if (document.images) {
      artists = new Image();
      artists.src = "images/artists.gif";
      artists_over = new Image();
      artists_over.src = "images/artists_over.gif";
    
      design = new Image();
      design.src = "images/design.gif";
      design_over = new Image();
      design_over.src = "images/design_over.gif";
    
      portfolio = new Image();
      portfolio.src = "images/portfolio.gif";
      portfolio_over = new Image();
      portfolio_over.src = "images/portfolio_over.gif";
    
      store = new Image();
      store.src = "images/store.gif";
      store_over = new Image();
      store_over.src = "images/store_over.gif";
    
      faq = new Image();
      faq.src = "images/faq.gif";
      faq_over = new Image();
      faq_over.src = "images/faq_over.gif";
      
      contact = new Image();
      contact.src = "images/contact.gif";
      contact_over = new Image();
      contact_over.src = "images/contact_over.gif";
      
      order = new Image();
      order.src = "images/order.gif";
      order_over = new Image();
      order_over.src = "images/order_over.gif";
    
      3d = new Image();
      3d.src = "images/3d.gif";
      3d_over = new Image();
      3d_over.src = "images/3d_over.gif";
     
    }
    
    function changeImages() {
      if (document.images) {
        for (var i=0; i<changeImages.arguments.length; i+=2) {
          document[changeImages.arguments[i]].src = eval(changeImages.arguments[i+1] + ".src");
        }
      }
    }
    It worked great, until I added the part for 3d.gif. I am totally baffled.

  2. #2
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    variables cannot start with a number. But, the underscore is ok...

    _3d = new Image();
    _3d.src = "images/3d.gif";
    _3d_over = new Image();
    _3d_over.src = "images/3d_over.gif";
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  3. #3
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, this had me breaking my head for the entire weekend. I just didn't think of a simple thing like that .


Bookmarks

Posting Permissions

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