var obj = new Object(); obj.Index = m; obj.name = CarsListInfo[i].ETCLockCode; obj.value = CarsListInfo[i].TruckCode; AttachEvent(markers[m], "click", LinkClick, obj);
function AttachEvent(target, eventName, handler, argsObject) { var eventHandler = handler; if (argsObject) { eventHander = function (e) { handler.call(argsObject, e); } } if (window.attachEvent)//IE try { target.attachEvent("on" + eventName, eventHander);//部分IE版本不支持此方法 } catch (e) { target["on" + eventName] = function () { //其他版本IE
alert(argsObject.name); alert(argsObject.value);
}; } else//FF target.addEventListener(eventName, eventHander, false); }
function LinkClick(e) { alert(this.name); alert(this.value); }