L
lawrence
I'm playing around with generating layer from a javascript. Strangely,
the code below works fine in FireFox when I assign a color to 'color'
but when I try to assign it to 'background-color' I get the error that
you see below. What is up?
<html>
<head>
</head>
<body>
<script type="text/javascript">
var left = 55;
var top = 0;
for (var i=0; i < 3000; i = i + 60) {
top = i + left;
top = top - i;
var nasty = "ID";
nasty += i;
document.write("<div id='ID" + i + "' style='position:absolute; top:"
+ top + "; left:" + left + "; background-color:#abc;'> <h2>God loves
you</h2> </div>");
left = 5 + i;
document.write(i);
document.write("<br>");
}
if (id = document.getElementById("ID60"))
document.getElementById("ID60").style.background-color = "#9af";
if (id = document.getElementById("ID120"))
document.getElementById("ID120").style.background-color = "#4af";
if (id = document.getElementById("ID180"))
document.getElementById("ID180").style.background-color = "#9a2";
</script>
</body>
Error: invalid assignment left-hand side
Source File: file:///C:/Documents%20and%20Settings/studio/Desktop/sesse/colorTest.htm
Line: 29, Column: 97
Source Code:
if (id = document.getElementById("ID60"))
document.getElementById("ID60").style.background-color = "#9af";
the code below works fine in FireFox when I assign a color to 'color'
but when I try to assign it to 'background-color' I get the error that
you see below. What is up?
<html>
<head>
</head>
<body>
<script type="text/javascript">
var left = 55;
var top = 0;
for (var i=0; i < 3000; i = i + 60) {
top = i + left;
top = top - i;
var nasty = "ID";
nasty += i;
document.write("<div id='ID" + i + "' style='position:absolute; top:"
+ top + "; left:" + left + "; background-color:#abc;'> <h2>God loves
you</h2> </div>");
left = 5 + i;
document.write(i);
document.write("<br>");
}
if (id = document.getElementById("ID60"))
document.getElementById("ID60").style.background-color = "#9af";
if (id = document.getElementById("ID120"))
document.getElementById("ID120").style.background-color = "#4af";
if (id = document.getElementById("ID180"))
document.getElementById("ID180").style.background-color = "#9a2";
</script>
</body>
Error: invalid assignment left-hand side
Source File: file:///C:/Documents%20and%20Settings/studio/Desktop/sesse/colorTest.htm
Line: 29, Column: 97
Source Code:
if (id = document.getElementById("ID60"))
document.getElementById("ID60").style.background-color = "#9af";