zoukankan      html  css  js  c++  java
  • FF下新增event对象的srcElement、fromElement、toElement三个属性

    网摘:

    ie下可以直接使用event对象的这三个属性

    现在我们需要为FF新增这三个属性:

    if(window.addEventListener) { FixPrototypeForGecko(); }  
    
      function  FixPrototypeForGecko()
      {
          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);
    
      }  
    
      function  element_prototype_get_runtimeStyle() { return  this.style; }
      function  window_prototype_get_event() { return  SearchEvent(); }
      function  event_prototype_get_srcElement() { return  this.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;
      }
    
      function  element_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;
      }
    
      function  SearchEvent()
      {
          if(document.all) return  window.event;  
    
          func = SearchEvent.caller;  
    
          while(func!=null){
              var  arg0=func.arguments[0];  
    
              if(arg0 instanceof Event) {
                  return  arg0;
              }
             func=func.caller;</pre><pre class="js">
          }
          return   null;
      }

    代码来自于:http://unmi.cc/ie-firefox-event-srcelement-fromelement-toelement

  • 相关阅读:
    C语言-define 与do{}while(0)
    Altium Designer 15 --- PCB 3D View
    算法工程师
    VS2015安装失败
    C++11新标准学习
    Sophus VS2010编译不支持?C++11语法的缘故。那有没有不带C++11特性的Sophus版本呢?
    如何学习C++? C++ Primer第三版中文版
    C++智能指针shared_ptr
    C++创建自己的库文件(dll文件创建和编译)
    ARKit对安卓的提示 ARKit与Google Tango
  • 原文地址:https://www.cnblogs.com/tatame/p/2779027.html
Copyright © 2011-2022 走看看