[Webkit-unassigned] [Bug 28630] City or Area selection check boxes don't work because document.activeElement doesn't work

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Sep 16 14:01:25 PDT 2010


https://bugs.webkit.org/show_bug.cgi?id=28630


Peter Lenahan <peter_lenahan at ibi.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |peter_lenahan at ibi.com




--- Comment #1 from Peter Lenahan <peter_lenahan at ibi.com>  2010-09-16 14:01:25 PST ---

Here is a JavaScript workaround to the ActiveElement problem in Safari and Chrome.

Add a listener on the mousedown event or any other event which you are depending on.

The event listener will keep the status of the active element, 
so when you want to reference it, you can use it.


// Declare a global variable to track the elements
var myActiveElement = null;


// define the event listener first
function _dom_trackActiveElement(evt) {
    if (evt && evt.target) { 
        myActiveElement= evt.target == document ? null : evt.target;
    }
}

if(navigator.userAgent.toLowerCase().indexOf('webkit') > -1)
{
    // Register the event listener here
    document.addEventListener("mousedown",_dom_trackActiveElement,true);
}


...
Now in a method where I need to use the activeElement, I have it available 
as a global variable it is always set in the event listener which tracks it.

    if (myActiveElement != null)
        myfunctioncall(myActiveElement);
    else
       myfunctioncall(document.activeElement);

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list