WebFX WebBoard
Message Thread:
View All Messages
Back to WebFX
 Adding functions with object prototyping, Micha Schopman, September 29, 2003
     Re:Adding functions with object prototyping, Wellington, September 29, 2003
         Re:Adding functions with object prototyping, Micha Schopman, September 29, 2003
         Re:Adding functions with object prototyping, Micha Schopman, September 29, 2003
             Re:Adding functions with object prototyping, Erik Arvidsson, September 30, 2003
             Re:Adding functions with object prototyping, Wellington, September 29, 2003

Subject: Adding functions with object prototyping From: Micha Schopman Date: September 29, 2003

I am completely stuck here. I try to add a function to an element I like to append. There must be something to get this working.

Could somebody give me a hint or help me out :(

I tried looking at how it is done in menu4.js but that is so confusing. I also want it so be msie proof, so it leaks as less memory as possible.

 

<script type="text/javascript">
 nodes = new Array();
 count = 0;
 
 function node(label,parentNode){
  this.label = label;
  this.parentNode = parentNode;
  this.add();
 }
 
 node.prototype.add = function(){
  this.newNode = document.createElement("DIV");
  this.newNode.className = 'node';
  this.newNode.innerHTML = 'new node' + count;
  this.newNode.attachEvent("onclick",this.remove);
  
  this.parentNode.appendChild(this.newNode);
  count++;
 }
 
 node.prototype.remove = function(){
  alert(this.label);
 }

</script>




Reply
Name: 
Email: 
Subject: 

Enter your reply to this message below. HTML tags are not supported but words that start with http://, ftp:// or mailto: are converted to links.


View All Messages
Back to WebFX