How to override a function in another javascript file?

I have a JavaScript file, Mybasefile.js , which has a Mybasefunction() function. I want to override this function in another JavaScript file. When a function is called by pressing a button, I want the original Mybasefunction() executed along with some other code. How can i do this?

+8
javascript override
source share
1 answer

put this code in the override file. Verify that the override file is included after the initial one.

 var orig_Mybasefunction = window.Mybasefunction; window.Mybasefunction = function(){ orig_Mybasefunction(); ... } 
+20
source share

All Articles