Whats wrong with this?

Discussion in 'Javascript' started by NeoPhreak, Aug 14, 2003.

  1. NeoPhreak

    NeoPhreak Guest

    This function is called on the onMouseOut even of a table cell for a menu.
    I want it to sort of fade out but for some reason i can't get it to work.
    If some one could help me out on this one i would greatly appreciate it.

    function out(obj)
    {
    var colors = new Array(5);
    colors[0]='#006666';
    colors[1]='#003333';
    colors[2]='#002222';
    colors[3]='#001111';
    colors[4]='';

    for(i=0; i<5; i++)
    {
    setTimeout("return","200");
    obj.style.backgroundColor= colors;
    }
    }

    would be called like this:
    <td onMouseOut="Out(this);">Something</td>

    Thanks in advance.

    NeoPhreak >.<
     
    NeoPhreak, Aug 14, 2003
    #1
    1. Advertising

  2. "NeoPhreak" <> writes:

    > This function is called on the onMouseOut even of a table cell for a menu.
    > I want it to sort of fade out but for some reason i can't get it to work.
    > If some one could help me out on this one i would greatly appreciate it.


    ....
    > setTimeout("return","200");


    What is this line supposed to do?
    What it actually does is to schedule the execution of the statement
    "return" in 200 milliseconds ... which ofcourse does nothing whatsoever.
    It doesn't delay execution of the following statements at all (which is
    what I guess you wanted it to).

    > would be called like this:
    > <td onMouseOut="Out(this);">Something</td>


    You function is called "out" with a small "o", but this call is to a
    function with a captial "O". Javascript is case sensitive.

    Try this:
    ---
    var colors = ["","#011","#022","#033","#066"];
    function fade(obj) {
    var ctr = colors.length-1;
    function fadeStep() {
    obj.style.backgroundColor = colors[ctr--];
    if (colors<0) {clearInterval(tid);}
    }
    var tid = setInterval(fadeStep,200);
    }
    ---

    /L
    --
    Lasse Reichstein Nielsen -
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
    'Faith without judgement merely degrades the spirit divine.'
     
    Lasse Reichstein Nielsen, Aug 14, 2003
    #2
    1. Advertising

  3. > var colors = new Array(5);
    > colors[0]='#006666';
    > colors[1]='#003333';
    > colors[2]='#002222';
    > colors[3]='#001111';
    > colors[4]='';


    You should consider using the array literal notation.

    var colors = ['#006666', '#003333', '#002222', '#001111', ''];

    It is smaller, faster, easier, prettier.

    http://www.JSON.org
     
    Douglas Crockford, Aug 14, 2003
    #3
  4. NeoPhreak

    NeoPhreak Guest

    Thanks guys.. got it working fine now :)

    NeoPhreak >.<
     
    NeoPhreak, Aug 15, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alexandre Martins

    Whats wrong with this provider ??

    Alexandre Martins, Aug 14, 2003, in forum: ASP .Net
    Replies:
    5
    Views:
    370
    Guenther Liebowitz
    Aug 14, 2003
  2. aa

    Whats wrong with numbers

    aa, Feb 6, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    315
    Patrice Scribe
    Feb 6, 2004
  3. sviau

    whats wrong with this header???

    sviau, Feb 6, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    594
    mikeb
    Feb 6, 2004
  4. aa

    Whats wrong

    aa, May 20, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,594
    Kevin Spencer
    May 20, 2004
  5. aa

    Whats wrong

    aa, May 26, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    347
    Natty Gur
    May 26, 2004
Loading...

Share This Page