FireFox 中對事件event的兼容擴展。

function __FireFox()
{
    HTMLElement.prototype.__defineGetter__("runtimeStyle", __element_style); 
    window.constructor.prototype.__defineGetter__("event", __window_event); 
    Event.prototype.__defineGetter__("srcElement", __event_srcElement); 
} 

function __element_style()
{ 
    return this.style; 
}

function __window_event()
{ 
    return __window_event_constructor(); 
}

function __window_event_constructor()
{
    var _caller = __window_event_constructor.caller; 
    while(_caller != null)
    {
        var _argument = _caller.arguments[0]; 
        if(_argument)
        { 
            var _ac = _argument.constructor; 
            if(_ac.toString().indexOf("Event") != -1)
            {
                return _argument;
            }
        }
        _caller = _caller.caller;
    }
    return null;
}

function __event_srcElement()
{
    return this.target; 
}

if(!document.all)
{
    __FireFox();
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章