[thelist] unobtrusive JS: adding events with parameters?

VOLKAN ÖZÇELİK volkan.ozcelik at gmail.com
Thu Jan 12 11:12:44 CST 2006


Here is how I do it in my js API (http://sardalya.sarmal.com/)

//define a proxy for retrieving events in a cross-browser manner.
var _this=EventObject.prototype;
function EventObject(evt){
	if(typeof(evt)=="undefined")this._evt=window.event;
	else this._evt=evt;
}

_this.getSource=function(){
	var e=this._evt;
	var src=e.srcElement?e.srcElement:(e.target?e.target:null);
	return src;
};

. . .

//this is the onclick event handler of your item.
function kButtonBool(evt){
	//this is what you need.
	var src=new EventObject(evt).getSource();
}

src gives exactly the source element (it is the same as this for your case).

HTH,
--
Volkan Ozcelik
+>Yep! I'm blogging! : http://www.volkanozcelik.com/volkanozcelik/blog/
+> My projects/studies/trials/errors : http://www.sarmal.com/



More information about the thelist mailing list