|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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> |
|
#2
|
||||
|
||||
|
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 |
![]() |
| Viewing: ASP Free Forums > Programming > HTML, JavaScript And CSS Help > Change back ground color in javascript |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|