JavaScript در layer اين يك مثال از :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>layers and java script</title>
<script language="JavaScript">
function showorhide(value){
obj=document.getElementById("layer3");
if(value==0)
obj.style.visibility="hidden";
else
obj.style.visibility="";
}
</script>
</head>
<body>
<h1>Controlling layer with javascript</h1>
<form name="form1">
<input type="Button" value="Show layer" onclick="showorhide(1);">
<input type="Button" value="Hide layer" onclick="showorhide(0);">
</form>
<p>This is a paragraph of normal text, outside all layers.</p>
<div id="layer1" style="position:static; background-color:lightgreen">
This is a static layer, positioned like a typical paragraph.
</div>
<p>This is another non-layer paragraph.</p>
<div id="layer2" style="position:absolute; left:50; top:250; width:200; height:200; background-color:yellow">
<p style="margin:2px,5px,2px,5px">This is a layer.</p>
<p style="margin:2px,5px,2px,5px"> kjsdvkjsdvjkbv</p>
</div>
<div id="layer3" style="position:absolute; left:50; top:250; width:100; background-color:darkblue; color:white; visibility:hidden">
This layer is not shown by defult, but can be displayed using javascript.
</div>
<div id="layer4" style="position:relative; left:150; top:100; width:200; height:100; background-color:lightblue">
This is the last layer.note taht the layers are displayed in the position we specify, and not necessarily in order.
</div>
</body>
</html>