开发者

How to override a function in another javascript file?

开发者 https://www.devze.com 2023-02-07 04:13 出处:网络
I have a JavaScript file, Mybasefile.js, which has the function Mybasefunction(). I want to override this function in another JavaScript file. When the function is called in开发者_Go百科 a button clic

I have a JavaScript file, Mybasefile.js, which has the function Mybasefunction(). I want to override this function in another JavaScript file. When the function is called in开发者_Go百科 a button click, I want the original Mybasefunction() to be executed along with some other code. How can I do this?


place this code in the override file. Make sure the override file is included after the orginal one.

var orig_Mybasefunction = window.Mybasefunction;
window.Mybasefunction = function(){
    orig_Mybasefunction();
    ...
}
0

精彩评论

暂无评论...
验证码 换一张
取 消