i wrote this script to test out the createElement and removeChild functions, it works fine in Mozilla, but in IE, it creates the DIV layer, but when i hit a key to activate the removeChild function it says that the DIV layer does not exist?
please help
thanks
Code:
<html>
<head>
</head>
<script language="JavaScript">
flag=false;
document.onkeydown=test;
function test() {
if(flag==false) {
layer=document.createElement("DIV");
layer.setAttribute("ID","testlayer");
layer.style.position="absolute";
layer.style.border="1px solid black";
layer.style.left=100;
layer.style.top=100;
layer.innerHTML="sdfsdf";
document.body.appendChild(layer);
flag=true;
} else {
layer=document.getElementById("testlayer");
layer.parentNode.removeChild(layer);
flag=false;
}
return false;
}
</script>
<body>
</body>
</html>
please help
thanks