User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 455,964 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,607 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 700 | Replies: 1
Reply
Join Date: Jul 2006
Location: Middle America
Posts: 173
Reputation: tefflox is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 1
tefflox's Avatar
tefflox tefflox is offline Offline
Junior Poster

Question Attempting to render shimmering text

  #1  
Nov 18th, 2007
Idea: each character of the text will shimmer in varied shades of gray.

Please help debug the code ---

// this is all in the <head>

  <script type="text/javascript">

  	var timer = null;

  	colors = new Array(14)
  	colors[0]="0"
  	colors[1]="1"
  	colors[2]="2"
  	colors[3]="3"
  	colors[4]="4"
  	colors[5]="5"
  	colors[5]="6"
  	colors[6]="7"
  	colors[7]="8"
  	colors[8]="9"
  	colors[9]="a"
  	colors[10]="b"
  	colors[11]="c"
  	colors[12]="d"
  	colors[13]="e"
  	colors[14]="f"

  function genHex(){

  	digit = new Array(2)
  	color=""
  	for (j=0;j<3;j++){
  		digit[j]=colors[Math.round(Math.random()*14)]
  		color = color+digit[j]+digit[j]+digit[j];
  	}
  	return color;
  }




  function alter() {
  	var i = Math.round(Math.random() * 15); // 15 is arbitrary
  	document.getElementById(i).style.color=genHex();	

  }

  function altTimer() {

  	timer = setInterval("alter();", 200);
  }
  </script>

<?php
  function line($str) {
    for($i = 0, $n = 0; $str[$i] != ""; $i++, $n++) 
      echo ("<span id=\"".$n."\">".$str[$i]."</span>");
  }
 ?>

// and this is in the <body>



  <?php
    line("this is a line of text");
   ?>        
  
  <script type="text/javascript">
    altTimer();
    </script>
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2007
Posts: 2,604
Reputation: MidiMagic is on a distinguished road 
Rep Power: 7
Solved Threads: 119
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Posting Maven

Re: Attempting to render shimmering text

  #2  
Nov 19th, 2007
You need an id on the object you want to make shimmer.

Also. most browsers will not update the screen until the script either ends or pauses execution (as in an alert statement).

You may need to recursively call your function with setInterval
Last edited by MidiMagic : Nov 19th, 2007 at 9:06 pm.
Daylight-saving time uses more gasoline
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 9:02 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC