you are in: codestackercodes [RSS] → tag: prototype [RSS]

[prototype] adding input:focus functionality to ie Delicious

show/hide lines
   1  Event.observe(window, 'load', function() { 
   2  var fields = $$("input"); 
   3  for (var i = 0; i fields[i].onfocus = function() {this.className += ' focused';} 
   4  fields[i].onblur = function() {this.className = this.className.replace('focused', '');} 
   5  } 
   6  }); 
   7  
   8  // in css, paste
   9  // input:focus, /* works in FF without javascript */ 
  10  // input.focused /* used by js */ 
  11  // { background-color: #f7cd72; } 
created by leozera — 18 November 2008 — get a short url — tags: hack ie6 javascript prototype embed

passing extra parameters to prototype observer handlers Delicious

a simple listener: $(’myForm’).observe(‘submit’, validateMyForm) dont support extra params in the function (in the case, validateMyForm. the solution:

show/hide lines
   1  $('myForm').observe('submit', function(event) {  
   2      validateMyForm(event, param1, param2);  
   3  }); 
created by leozera — 05 August 2008 — get a short url — tags: javascript prototype embed