SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot Da Mouse's Avatar
    Join Date
    Aug 2002
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Tiny script not working

    Can anyone sort this out?
    it keeps saying line 11 object required

    Code:
    <script type="text/javascript">
    <!--
    function togglemen()
    {
     if (document.layers) 
     {
      var slider = document.layers[ted];
     } 
     else if (document.all) 
     {
      var slider = document.all(ted).style;
     }
     while(slider.left < 100)
     {
     setTimeout(slider.left++,1000);
     }
    }
    //-->
    </script>
    <div id="ted" name="ted" style="height:10;width:100;position:absolute;left:-100;top:0;background-color:red;">
    Can You See Me!
    </div>
    <a href="#" onclick="togglemen(); return false;">Show Me</a>
    I am DaMouse
    Nobody can beat me so long as I'm stubborn -DaMouse
    Squeak

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)

    Re: Tiny script not working

    You forgot to put 'ted' in quotes, as well as forgetting document.getElementById (for browsers that USE the standard, i.e. NS6/7, IE6/PC, IE5/Mac, Konqueror/Linux).

    Here's my fix:

    Code:
    <script type="text/javascript" language="javascript">
    <!--
    function togglemen()
    var slider;
    {
     if (document.layers) 
     {
      slider = document.layers['ted'];
     } 
     else if (document.all) 
     {
      slider = document.all['ted'].style;
     }
     else //this is document.getElementById!
     {
     slider = document.getElementById('ted').style;
     }
     while(slider.left < 100)
     {
     setTimeout(slider.left++,1000);
     }
    }
    //-->
    </script>
    <div id="ted" name="ted" style="height:10;width:100;position:absolute;left:-100;top:0;background-color:red;">
    Can You See Me!
    </div>
    <a href="#" onclick="togglemen(); return false;">Show Me</a>
    Also, for Netscape 4 (document.layers) you need a <layer> tag.

    Hope this helps!

    --Vinnie

  3. #3
    SitePoint Zealot Da Mouse's Avatar
    Join Date
    Aug 2002
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope that doesn't work in IE and doesn't slide in opera

    the red square is suppost to slide in from the left
    I am DaMouse
    Nobody can beat me so long as I'm stubborn -DaMouse
    Squeak

  4. #4
    SitePoint Zealot Da Mouse's Avatar
    Join Date
    Aug 2002
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    umm I've got it slightly working in Opera can you please have a look at this site USS Atlantis and see the error in IE
    I am DaMouse
    Nobody can beat me so long as I'm stubborn -DaMouse
    Squeak

  5. #5
    SitePoint Zealot Da Mouse's Avatar
    Join Date
    Aug 2002
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    never mind I changed the menu style
    I am DaMouse
    Nobody can beat me so long as I'm stubborn -DaMouse
    Squeak


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
  •