With jquery, it would be pretty easy to just add in another function to use. Try something like:
//Sample function you're wrapping around
function say_hi(){
alert('hi');
}
//quick jq plugin
jQuery.fn.functionWrap = function(arg,opts){
if(opts.before && typeof(opts.before)=='function'){
opts.before();
}
arg();
if(opts.after && typeof(opts.after)=='function'){
opts.after();
}
};
//sample function to use the wrapper func
function btnPress(){
$().functionWrap(
say_hi,
{
before : function(){ alert('happens before'); },
after : function(){ alert('happens after'); }
}
);
}
Try adding that to your page, and something like this to test it out:
<input type="button" value="asdf" onClick="btnPress();" />
Hope this helps you.