Pages

Tuesday, 2 July 2013

How To Generate Random Colors in JavaScript Or Random Color Generator in JavaScript in c# Asp.Net

How To Generate Random Colors in JavaScript Or Random Color Generator in JavaScript in c# Asp.Net


Program:

.Aspx File:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Random Colors</title>
    <script type="text/javascript">

        setInterval(rgbcolors, 1000);
        function rgbcolors() {

            var col = "rgb(" + Math.floor(Math.random() * 255) + "," + Math.floor(Math.random() * 255) + "," + Math.floor(Math.random() * 255) + ")";
            document.getElementById("divstyle").style.color = col;
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div id="divstyle" style="font: bold 24px verdana">
        Sizar Surani</div>
    </form>
</body>

Live Demo:

Random Colors
Sizar Surani

No comments:

Post a Comment