Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 26th, 2012  |  syntax: None  |  size: 0.46 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to set the receiver
  2. foo = function(arg1,arg2){....};
  3.        
  4. arg1.foo(arg2);
  5.        
  6. var arg1 = {
  7.     foo: function(arg2) { }
  8. };
  9.  
  10. arg1.foo(arg2)
  11.        
  12. var test = document.getElementById('test');
  13.  
  14. test.foo = function(arg) {
  15.     alert(this.innerHTML + " : " + arg);
  16. };
  17.  
  18. test.foo("Hello");
  19.        
  20. function foo(arg1, arg2) {
  21.    if (typeof arg1 == 'function')
  22.       arg1(arg2); // or 'return arg1(arg2)' if necessary
  23.    else
  24.       return false;
  25. }
  26.        
  27. foo(alert,'hello world');