Hi Nacho
Well, you've got a couple of choices I guess:
1) Publicly declare 'message' so that it can be referenced outside of the function that created it. You could do that simple by declaring it before the start of the function.
e.g.
Code:
<SCRIPT LANGUAGE=javascript>
<!--
var message=document.createElement('div');
function creatediv()
{
message.style.position="absolute";
message.style.width=200;
message.style.height=70;
message.style.left=200;
message.style.top=50;
message.innerHTML='hello';
document.getElementsByTagName('body').item(0).appe ndChild(message);
}
//-->
</SCRIPT>
or (and this would be my preference)
2) Assign an id to the div so that you can refence it from anywhere.
e.g.
Code:
<SCRIPT LANGUAGE=javascript>
<!--
function creatediv()
{
var message=document.createElement('div');
message.style.position="absolute";
message.style.width=200;
message.style.height=70;
message.style.left=200;
message.style.top=50;
message.innerHTML='hello';
message.id = "mydiv";
document.getElementsByTagName('body').item(0).appe ndChild(message);
}
//-->
</SCRIPT>
Then, when you want to reference the div, use it's id 'mydiv'.
Lastly, the code you pasted above for changing the background colour and the z-Index is wrong. If you were using my preferred solution above (2), it would be:
mydiv.style.backgroundColor = "#0066FF"
mydiv.style.zIndex="2"
That pretty much covers it.
