Marc Luzietti wrote:
    > Is there a way to use JavaScript and the
    > Dom to make an element be focusable?

Here's a script for I often use applying focus to form elements for IE. I 
call it focus_js.js and It could be used for anything, they just need to be 
added as indicated below. If used with another script, just add it to the 
existing script file.

// Begin scripting
window.onload = function() {

 // What elements do you want to assign which events to? ADD more as needed.
 var objEvt = {
  input   : ["hover", "focus"],
  select  : ["hover", "focus"],
  textarea: ["hover", "focus"]
 };

 // spare use variables
 var temp, tempLen = 0;

 // hover/focus functions
 function hoverFunc  (){this.className += ' hover';}
 function unHoverFunc(){this.className = this.className.replace(' hover', 
'');}
 function focusFunc  (){this.className += ' focus';
  if(navigator.appName.indexOf('Explorer')!=-1){

// For clearing a URL/web address input of placeholder except http://
   if(this.value==this.defaultValue&&this.name=='url') this.value='http://';
  }
 }
 function unFocusFunc(){this.className = this.className.replace(' focus', 
'');}

 for(var i in objEvt){
  temp = document.getElementsByTagName(i), tempLen = temp.length;
   for(var j=0; j<tempLen; j++){
    for(var k=0; k<objEvt[i].length; k++){
     if(objEvt[i][k] == 'hover'){
      temp[j].onmouseover = hoverFunc;
      temp[j].onmouseout  = unHoverFunc;
     } else if(objEvt[i][k] == 'focus'){
      temp[j].onfocus = focusFunc;
      temp[j].onblur  = unFocusFunc;
     }
    }
   }
 }
}
// End scripting

To use it you link it like any other script then wherever you have the 
:hover and :focus pseudo elements in your CSS, add .hover and .focus 
classes.

:active isn't used in this case.

Hope this helps.

Respectfully,
Mike Cherim
http://green-beast.com/



*******************************************************************
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
*******************************************************************



*******************************************************************
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
*******************************************************************

Reply via email to