• Welcome! The TrekBBS is the number one place to chat about Star Trek with like-minded fans.
    If you are not already a member then please register an account and join in the discussion!

CSS to Javascript conversion

That Weirdo In The Corner

Commander
Red Shirt
Can anyone help me by telling me what the Javascript version of the css below would be I'm trying to change the background colour every two seconds. :confused:

.bridge > .alarm{

background-color:#CC0000;
}
 
Here's a little example I did just now changing the background color to a random color every 2 seconds.
Cheers.

-Jamman

Code:
<html>
<script language="javascript">
    function ChangeBackground()
    {
        document.bgColor = GenerateRandomColor();
    }
 
    function GenerateRandomColor()
    {
        var color = "#";
        var ceiling = 6;
        var hexTable = "0123456789ABCDEF";
        var hexCeiling = 15;
        for(var i = 0; i<ceiling; ++i)
        {
            randomHex = Math.floor(Math.random() * hexCeiling);
            color += hexTable.charAt(randomHex);
        }
        return color;
    }
 
    setInterval(ChangeBackground, 2000);
</script>
</html>
 
If you are not already a member then please register an account and join in the discussion!

Sign up / Register


Back
Top