Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: eval usage


Message #1 by "wenjun deng" <denwe02@c...> on Fri, 22 Jun 2001 20:20:53
Hi, I'm beginner of js. I'm confused about the usage of "eval" in the 
following code. Can we take off it? When shall we use it, when not? 
Thanks!
Wendy
-------------------------------------------------

function makeElement(whichEl,whichContainer) {
  if (arguments.length==1)
    whichContainer = (NS4) ? window : document.body;

  if (NS4) {
    eval(whichEl + "= new Layer(menuWidth,whichContainer)");
  }
  else {
    elStr = "<DIV ID=" + whichEl + " STYLE='position:absolute'></DIV>";
    whichContainer.insertAdjacentHTML("BeforeEnd",elStr);
  }

  return eval(whichEl);
}

  Return to Index