View Single Post

  #3 (permalink)  
Old 04-16-2004, 08:22 AM
chore_ashwin
Guest
 
Posts: n/a
Default thanks

Thanks for ur support
It is working fine

But i have another problem. It seems that after calling afunction with setTimeout() Execution proceeds imidiately to the next statement......
If i want to acess the elements that are created in a function called with setTimeout(), I cant acess them as the element is not created yet so It flags the Err as "null is null or not an object"

How do i control that this statement is executed after the element is created

ex
<svg onload="init(evt)" >
<script language="javascript">
<![CDATA[
var svgDocument=null;
var svgns ="http://www.w3.org/2000/svg";
var node;
var svgDocument;
var Timer=0

function init(event){
svgDocument= event.target.ownerDocument;
Timer=setTimeout("createCircle(1)",1000);
// i think err is flaged due to this statement as element is yet not created
//Am i correct
var tgtElement=svgDocument.getElementById(0);
tgtElement.setAttribute("fill","blue");

}




function createCircle(c){
var i=c
node = svgDocument.createElementNS(svgns, "circle");
node.setAttributeNS(null, "id",i);
node.setAttributeNS(null, "cx",i*50);
node.setAttributeNS(null, "cy",50);
node.setAttributeNS(null, "r", 15);
node.setAttributeNS(null,"fill", "yellow");
svgDocument.documentElement.appendChild(node);




if(i<3){

i++

Timer=setTimeout("createCircle("+i+")",1000);

}

}

]]>
</script>
</svg>

please tell me how do i solve it
Reply With Quote