SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Mar 2006
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting the current element in focus FF

    Hey,
    document.activeElement seems to work fine in IE but not FF.
    Is there an alternative to this for FF.

    Thanks.
    Brian

  2. #2
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you insist, you have to write your own.
    Code:
    if(document.activeElement===undefined && document.addEventListener){
        var A=document.getElementsByTagName('*');
        var L=A.length;
        while(L){
            var tem=A[--L];
            if(tem.addEventListener!==undefined &&   tem.focus!==undefined){
                tem.addEventListener('focus',function(){
                    document.activeElement=tem;}, false);
                tem.addEventListener('blur',function(){
                    document.activeElement='';},false);}
        }
    }

  3. #3
    SitePoint Member
    Join Date
    Mar 2006
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, thanks


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •