FF下新增event对象的srcElement、fromElement、toElement三个属性
<div id="cnblogs_post_body">网摘:ie下可以直接使用event对象的这三个属性
现在我们需要为FF新增这三个属性:
<div class="cnblogs_code">if(window.addEventListener) { FixPrototypeForGecko(); } functionFixPrototypeForGecko(){ HTMLElement.prototype.__defineGetter__("runtimeStyle",element_prototype_get_runtimeStyle); window.constructor.prototype.__defineGetter__("event",window_prototype_get_event); Event.prototype.__defineGetter__("srcElement",event_prototype_get_srcElement); Event.prototype.__defineGetter__("fromElement",element_prototype_get_fromElement); Event.prototype.__defineGetter__("toElement", element_prototype_get_toElement);} functionelement_prototype_get_runtimeStyle() { returnthis.style; }functionwindow_prototype_get_event() { returnSearchEvent(); }functionevent_prototype_get_srcElement() { returnthis.target; } function element_prototype_get_fromElement() { var node; if(this.type == "mouseover") node = this.relatedTarget; else if (this.type == "mouseout") node = this.target; if(!node) return; while (node.nodeType != 1) node = node.parentNode; return node;}functionelement_prototype_get_toElement() { var node; if(this.type == "mouseout")node = this.relatedTarget; else if (this.type == "mouseover") node = this.target; if(!node) return; while (node.nodeType != 1) node = node.parentNode; return node;}functionSearchEvent(){ if(document.all) returnwindow.event; func = SearchEvent.caller; while(func!=null){ vararg0=func.arguments]; if(arg0 instanceof Event) { returnarg0; } func=func.caller;</pre><pre class="brush:js"> } return null;}
页:
[1]