In this case you could omit tmpObject completely, just write
aDiv.onclick = function () {
var tmpFunc = aDiv.onclick;
return function () {
tmpFunc.apply(this, arguments);
someAnotherFunc();
}
}();
But what about using addEventListener/attachEvent instead of assigning
to .onclick?
On Wed, Dec 15, 2010 at 2:03 PM, Yu-Hsuan Lai <[email protected]> wrote:
> I found a solution, but I think it's not clever:
> (If possible I wouldn't like to change origin onclick because it's in
> another file)
> aDiv.onclick = function () {
> var tmpFunc = aDiv.onclick;
> var tmpObject = aDiv;
> return function () {
> tmpFunc.apply(tmpObject);
> someAnotherFunc();
> }
> }();
--
Kai-Chieh Ku
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]