Whats wrong with this?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • NeoPhreak

    Whats wrong with this?

    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("ret urn","200");
    obj.style.backg roundColor= colors[i];
    }
    }

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

    Thanks in advance.

    NeoPhreak >.<


  • Lasse Reichstein Nielsen

    #2
    Re: Whats wrong with this?

    "NeoPhreak" <neo@neophreak. com> writes:
    [color=blue]
    > 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.[/color]

    ....[color=blue]
    > setTimeout("ret urn","200");[/color]

    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).
    [color=blue]
    > would be called like this:
    > <td onMouseOut="Out (this);">Someth ing</td>[/color]

    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.backg roundColor = colors[ctr--];
    if (colors<0) {clearInterval( tid);}
    }
    var tid = setInterval(fad eStep,200);
    }
    ---

    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    • Douglas Crockford

      #3
      Re: Whats wrong with this?

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

      You should consider using the array literal notation.

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

      It is smaller, faster, easier, prettier.




      Comment

      • NeoPhreak

        #4
        Re: Whats wrong with this?

        Thanks guys.. got it working fine now :)

        NeoPhreak >.<


        Comment

        Working...