Sometimes it is required to override the onclick values pre-populated by server to implement our own handlers and also call the overriden functions. The code below does this very reliably without any browser specific hacks.
<button onclick="someFunc(arg1, arg2)">Click Me</button>
I wanted to run my own operations on the click of this button and then call someFunc(arg1, arg2). I searched but did not get any solution (surprisingly).
I could have easily used eval or Function to parse the onclick value and run it after my operations were complete but to avoid the eval way I invented a simpler solution.
I created a dummy anchor element and set its onclick to the onclick of the button, then removed the onclick from the button registered and added a new function to execute on click of the button. In this function I performed the required operations and then triggered the click of the dummy element. Thus I was able to execute both my operations and the default operations (someFunc(arg1, arg2)))
Please share if you have any other better techniques to accomplish this