PDA

View Full Version : checking what element is focused?


sir pannels
07-10-2008, 01:23 PM
hi all,

does anyone know if its possible to see what html page element currently has focus and return the element id?

any info be great

many thanks

abduraooft
07-10-2008, 01:29 PM
Try something like
window.onload=function(){
var elmts=document.getElementById('myform_id').elements.
for(var i=0;i<elmts.length;i++){
elmts[i].onfocus=function(){
if(this.hasAttribute('id'))
alert(this.getAttribute('id'));
}
}
}

rnd me
07-10-2008, 01:32 PM
in ff3+IE: document.activeElement