简体   繁体   中英

how to override setTimeOut function in javascript

I am using ckeditor plugin in grails. I have this function in ckeditor.js

setTimeout(function(){var u=t.getInputElement();
    u&&u.$.focus();
},0)

setTimeout(function(){var u=t.getInputElement();
    if(u){ 
    u.$.focus();
    u.$.select();}},0)

I need to change time out from 0 to say 10000. Now the problem is I that I have asked not to touch ckeditor.js file since it is plugin file and it is used at many places. So I should make changes in some local file which imports ckeditor.js.

So how should I override this function or do something else to change the value of timeout function

create a new javascript file and write the following method

  (function() {
    var oldsetTimeout = setTimeout;
    setTimeout = extendedsetTimeout;
    function extendedsetTimeout() {
       setTimeout();//call old method
       doSomething();
    }
 })();

Good advice: debug source files, not built and minified version...

You most likely mean these lines . Just override CKEDITOR.ui.dialog.textInput.prototype.focus function with your own one and that's it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM