Generate and destroy layers : Layer Creation « Ajax Layer « JavaScript DHTML






Generate and destroy layers


http://dynapi.sourceforge.net/
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999       
<html>
<head>
<title>DynAPI - DynLayer Destroy</title>
<script language="JavaScript" src="./dynapisrc/dynapi.js"></script>
<script language="Javascript">
dynapi.library.setPath('./dynapisrc/');
dynapi.library.include('dynapi.api');
dynapi.library.include('dynapi.functions');
</script>
<script language="Javascript">

dynapi.onLoad(init);
function init() {
  document.countform.counttext.value = 0;
};

var counter = 0;
function generate(n) {
  for (var i=0;i<n;i++) {
    var d = new DynLayer();
    d.setBgColor(dynapi.functions.getRandomColor());
    d.setSize(10+80*Math.random(),10+80*Math.random());
    d.setLocation(130+500*Math.random(),500*Math.random());
    dynapi.document.addChild(d);
    counter++;
    document.countform.counttext.value = counter;
  }
}

var timer;
function start() {
  timer = setInterval('generate(10)',1);
}
function stop() {
  clearInterval(timer);
}

function destroyAll() {
  dynapi.document.destroyAllChildren();
  document.countform.counttext.value = 0;
}

</script>
</head>
<body bgcolor="#999999">

<p><a href="javascript:start()">Start generation</a><br>
<a href="javascript:stop()">Stop generation</a><br>
<a href="javascript:destroyAll()">Destroy all</a><br>

<form name="countform">
<input type=text name="counttext" size=5>
</form>

</body>
</html>


           
       








dynapi.zip( 791 k)

Related examples in the same category

1.Layer Create/Remove/Delete
2.This is an inline layer that was created after page load
3.Relative Layers : Dynamic creation example
4.Relative Layers : Basic example
5.Layer Inline
6.Relative Layers