• AddEventListener 如何传递函数参数


    var EventUtil = new Object;
                    EventUtil.addEventHandler = function (oTarget, sEventType, fnHandler) {
                        if (oTarget.addEventListener) {
                            oTarget.addEventListener(sEventType, fnHandler, false);
                        } else if (oTarget.attachEvent) {
                            oTarget.attachEvent("on" + sEventType, fnHandler);
                        } else {
                            oTarget["on" + sEventType] = fnHandler;
                        }
                    };
                   
                            
                    function handleOnblur(div) {
                        
                        alert(div.id);
                    }               

          var o = function(){
                             var oDiv = document.getElementById("div1");
                            handleOnblur(oDiv);
                        }

                    window.onload = function() {
                        var oDiv = document.getElementById("div1");   

                        EventUtil.addEventHandler(oDiv, "blur", o);
                    }

    可以使用上面这种方式,也可以使用prototype 方式。

      function handleOnblur() {
                        alert(handleOnblur.prototype.addObject);
                    }           

    var oDiv = document.getElementById("div1");

    handleOnblur.prototype.addObject = oDiv;

  • 相关阅读:
    python剑指网络篇二
    使用sklean进行多分类下的二分类
    virtualenv下使用matplotlib
    谱聚类python实践
    K均值算法-python实现
    python使用hbase
    php运算符
    php常量
    php数据类型
    git,版本控制教程
  • 原文地址:https://www.cnblogs.com/wblade/p/1668926.html
Copyright © 2020-2023  润新知