HTML, JavaScript And CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingHTML, JavaScript And CSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old July 13th, 2004, 05:41 AM
kaleem_ullah kaleem_ullah is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 2 kaleem_ullah User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Post Change back ground color in javascript

I have written this code in javascript and its not working correctly. The main function of this code is to change background color automatically after certain time. plz tell me what's wrong with that code and this code weill activate when page load.
Here is the Code:-
<script language="javascript">
var colours = new Array ("#CC0000","#CC6699","#000000")
var Bcolor = 0;
var Tcolor = 3;
function rotateBG(){
if(document.images) {
Bcolor++;
if(Bcolor == Tcolor) {
Bcolor = 0;
}
document.bgcolor=colours[Bcolor]
setTimeout ("rotateBG()", 3 * 100)
}
}
</script>

Reply With Quote
  #2  
Old July 15th, 2004, 03:28 AM
selwonk's Avatar
selwonk selwonk is offline
Contributing User
ASP Free Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2004
Posts: 2,942 selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 6 Days 9 h 49 m 28 sec
Reputation Power: 62
Hi

Try this:

Code:
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Change background colour</title>
<script language="JavaScript">
function RotateBG() {
 window.setTimeout( "RotateBG()", 3000);
 var intRandom = Math.round(Math.random() * 3);
 var strColor = "FFFFFF";
 if (intRandom == 1) strColor = "CC0000";
 if (intRandom == 2) strColor = "CC6699";
 if (intRandom == 3) strColor = "000000";
 document.bgColor = strColor;
}
</script>
</head>
<body onLoad="RotateBG();">
</body>
</html>


MK

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingHTML, JavaScript And CSS Help > Change back ground color in javascript


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT