Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jul 29th, 2010  |  syntax: HTML  |  size: 0.78 KB  |  views: 39  |  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. This example works as I expected both to work
  2.  
  3. <html>
  4. <body>
  5. <input id="txt" type="textbox" onblur="foo('?')">
  6.  
  7. <script>
  8. var txt = document.getElementById("txt");
  9.  
  10.  
  11. txt.prototype={original: txt.onblur};
  12. txt.onblur=bar;
  13.  
  14. function foo(ctl)
  15. {
  16.  alert("foo " + ctl);
  17. }
  18. function bar()
  19. {
  20.  alert("bar");
  21.  this.prototype.original();
  22. }
  23.  
  24. </script>
  25. </body>
  26. </html>
  27.  
  28.  
  29.  
  30.  
  31. This example has an undefined value, as it tries to pass the this object
  32.  
  33. <html>
  34. <body>
  35. <input id="txt" type="textbox" onblur="foo(this)">
  36.  
  37. <script>
  38. var txt = document.getElementById("txt");
  39.  
  40.  
  41. txt.prototype={original: txt.onblur};
  42. txt.onblur=bar;
  43.  
  44. function foo(ctl)
  45. {
  46.  alert("foo " + ctl.id);
  47. }
  48. function bar()
  49. {
  50.  alert("bar");
  51.  this.prototype.original();
  52. }
  53.  
  54. </script>
  55. </body>
  56. </html>
clone this paste RAW Paste Data