Announcement

Collapse
No announcement yet.

Javascript? Making a background color blink.

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

  • Javascript? Making a background color blink.

    I'm trying to get a background color of a cell to blink.
    Actually I'm not trying, I don't even know where to start.

    This is for a new little hack. I know I can use a blinking .gif image and use it as the background, but using a javascript would be a *lot* better.

    Thanks for any help!
    Chen Avinadav
    Better to remain silent and be thought a fool than to speak out and remove all doubt.

    גם אני מאוכזב מסיקור תחרות לתור מוטור של NRG הרשת ע"י מעריב

  • #2
    This should do the trick:

    Code:
    <HEAD>
    
    <SCRIPT LANGUAGE="JavaScript">
    
    <!-- Begin
    function blinkit(){
    intrvl=0;
    for(nTimes=0;nTimes<3;nTimes++){
    intrvl += 1000;
    setTimeout("document.bgColor='#0000FF';",intrvl);
    intrvl += 1000;
    setTimeout("document.bgColor='#FFFFFF';",intrvl);
       }
    }
    // End -->
    </SCRIPT>
    
    <BODY>
    <CENTER>
    <FORM>
    <INPUT TYPE="BUTTON" VALUE="Blink" onClick="blinkit()">
    </FORM>
    The first bit in bold, add lines to like that after it to increase the amount of colours.

    The second bit in bold indicates when this is called and started/used. Just put that whenever you want it to start.
    Email: [email protected]
    Site: Under Construction

    Comment


    • #3
      Thanks.
      I had to manipulate it a bit, I put onLoad="blinkIt()" in the <body> tag, and also made it quicker and infinite.
      Chen Avinadav
      Better to remain silent and be thought a fool than to speak out and remove all doubt.

      גם אני מאוכזב מסיקור תחרות לתור מוטור של NRG הרשת ע"י מעריב

      Comment


      • #4
        your welcome

        *me tells Firefly to stop bowing to my wisdom and also tells him i am the last poster again

        heheheheh
        Email: [email protected]
        Site: Under Construction

        Comment


        • #5
          Ok I thought I made it blinking forever, but I can't.
          If I set the for() loop to go on no matter what my IE freezes.
          Chen Avinadav
          Better to remain silent and be thought a fool than to speak out and remove all doubt.

          גם אני מאוכזב מסיקור תחרות לתור מוטור של NRG הרשת ע"י מעריב

          Comment


          • #6
            Never mind, I found a better script that does exactly what I need.

            It was written by Statik but I modified it a bit:
            Code:
            <html>
            <head>
            <title>Blink Text</title>
            </head>
            <body>
            <table align="center" width="50%" height="50%">
            	<tr>
            		<td id="pmBox" align="center"><font face="verdana" size="2">Let's Blink!</font></td>
            	</tr>
            </table>
            <script language="JavaScript">
            <!-- Begin
            pmBox.bgColor='#FFFFFF';
            setInterval("Timer()", 500);
            x=1;
            function Timer() {
            	set=1;
            	if(x==0 && set==1) {
            		pmBox.bgColor='#EEEEEE';
            		x=1;
            		set=0;
            	}
            	if(x==1 && set==1) {
            		pmBox.bgColor='#FFFFFF';
            		x=0;
            		set=0;
            	}
            }
            // End -->
            </script>
            </body>
            </html>
            Chen Avinadav
            Better to remain silent and be thought a fool than to speak out and remove all doubt.

            גם אני מאוכזב מסיקור תחרות לתור מוטור של NRG הרשת ע"י מעריב

            Comment


            • #7
              Originally posted by Chen View Post
              Never mind, I found a better script that does exactly what I need.

              It was written by Statik but I modified it a bit:
              Code:
              <html>
              <head>
              <title>Blink Text</title>
              </head>
              <body>
              <table align="center" width="50%" height="50%">
                  <tr>
                      <td id="pmBox" align="center"><font face="verdana" size="2">Let's Blink!</font></td>
                  </tr>
              </table>
              <script language="JavaScript">
              <!-- Begin
              pmBox.bgColor='#FFFFFF';
              setInterval("Timer()", 500);
              x=1;
              function Timer() {
                  set=1;
                  if(x==0 && set==1) {
                      pmBox.bgColor='#EEEEEE';
                      x=1;
                      set=0;
                  }
                  if(x==1 && set==1) {
                      pmBox.bgColor='#FFFFFF';
                      x=0;
                      set=0;
                  }
              }
              // End -->
              </script>
              </body>
              </html>

              can i use this to make a user name blink in the forum..and where do i add the code if i can use it

              ty

              Comment

              Related Topics

              Collapse

              Working...
              X