My goal for my webpage is to have the background be a random string of 0's and 1's that changes at a set time interval. If you run the following code, you will see that I have accomplished the task. However, I need to resolve 2 problems before moving on:
(1) How do I make the string of 0's and 1's fit exactly in the container in which they reside? Or is that even possible? I did a hack-job of changing the length of the string until it overflowed and hiding the overflow.
(2) How do I construct the rest of my page on top of that background? Was I right to make the background a div? I tried to follow what was done here: Is there a way to use use text as the background with CSS?
<html>
<head>
<title>my site</title>
<style type="text/css">
#mtx_bckgd
{
z-index: -1;
font-family: Courier New;
height: 1000px;
width: 1000px;
}
#mtx_bckgd > p
{
word-wrap: break-word;
color: #D8D8D8;
}
</style>
<script type="text/javascript">
function change_bckgd()
{
var bitstr = "";
for (var i = 0; i < 4000; ++i)
bitstr += Math.floor(Math.random()*10) % 2 ? "0" : "1";
document.getElementById("mtx_txt").innerHTML = bitstr;
}
</script>
</head>
<body>
<div id="mtx_bckgd">
<p id="mtx_txt"></p>
</div>
<script type="text/javascript">
setInterval(change_bckgd, 200);
</script>
</body>
</html>