2009-08-23 136 views
2

我想知道如何在發生其他事情之前觸發默認動作。特別是,我正在使用第三方庫,如果我使用事件處理程序並調用其中一個函數,它們將覆蓋默認操作。因此,作爲解決方法,我希望默認操作在其庫函數被調用之前發生。在事件處理程序中觸發javascript默認動作

有沒有辦法做到這一點?

非常感謝!

回答

4

我假設你的意思是你想在事件被瀏覽器處理後調用它們的函數。

爲此,請在延遲後使用setTimeout方法執行。

例如,

//In the event handler: 
setTimeout(function() { 
    //This code will execute 5 milliseconds later, and only after your code finishes. 
    //Call their function here 
}, 5); //That means a 5 millisecond delay. 
     //You can increase it if you want to. 
相關問題