Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is wrong with this? EASY! 1

Status
Not open for further replies.

MikeBarone

Programmer
Mar 1, 2001
354
US
I am trying to get the bgcolor to blink red when the button is pressed.


Code:
<FORM><INPUT TYPE="button" NAME="Button" Value="CONTACT US" onClick="document.bgColor='#FF0000'; setTimeout(document.bgColor='#FFFFFF', 5000);"></FORM>

-
Mike
FREE CGI/Perl/JavaScripts
 
I couldn't tell you why it wasn't working; I know when I have JS problems with setTimeout, I can normally resolve it by assigning the return value of setTimeout to a variable, such as follows:
Code:
<script type="text/javascript">
function toggleBg() {
  document.bgColor = "#FF0000" ;
  var resetTimeout = setTimeout("document.bgColor='#FFFFFF'", 5000) ;
}
</script>
 ...

<FORM><INPUT TYPE="button" NAME="Button" Value="CONTACT US" onClick="toggleBg();"></FORM>
This is tested in Firefox only.


Greg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top