Or, in its own meta tag Or, as one of your keywords

Friday, 6 January 2012

Colourfull Squares with Java script.

You can copy and paste this in your notepad and save it as .html file to see the magic.
<Made by the mastersinner (HBH)____ >
<html>
<head>
<script type="text/javascript">
var hex = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F");
var i;

function drawsquare(e) {
var square = document.createElement("div");
square.className = "square";
square.style.backgroundColor = rndcolor();
square.style.left = e.clientX + "px";
square.style.top = e.clientY + "px";
document.body.appendChild(square);
}

function rndcolor() {
var color = "#";
for (i=0; i<6; i++) {
color += hex[Math.floor(Math.random() * 16)];
}
return color;
}
</script>
<style>
body {
overflow: hidden;
}

.square {
position: absolute;
width: 25px;
height: 25px;
}
</style>
</head>
<body onmousemove="drawsquare(event);">

</body>
</html>

No comments:

Post a Comment