2013-08-07 58 views
0

我有一個刷新功能如何確保一個函數在其他函數之後獲取觸發器?

function refresh(nRefresh) 
{ 
TimerSetting = document.all.curRefresh.Timer; 
document.all.curRefresh.Timer = 'On';  
nTimeOut = nRefresh; 
updateKnlButtons(); 
psStatusUpdate(); 
} 

此功能重新加載頁面。 點擊一個按鈕後,我給刷新(5)5秒後刷新頁面。由於某些原因,我想完成刷新功能之後觸發功能,但該功能被炒魷魚之前刷新功能是completed.How確保禁止函數被調用時完成刷新功能後

function disableButton() 
{ 
idStopSelBtn.style.cursor='wait'; 
idStartSelBtn.style.cursor='wait'; 
idBounceRunningBtn.style.cursor='wait'; 
idStopAllBtn.style.cursor='wait'; 
idStartAllBtn.style.cursor='wait'; 
idBounceSelBtn.style.cursor='wait' 
idStopSelBtn.src='images/Button/Disabled/Stop-Selected.gif'; 
idStartSelBtn.src='images/Button/Disabled/Start-Selected.gif'; 
idBounceRunningBtn.src='images/Button/Disabled/Bounce-Running.gif'; 
idStopAllBtn.src='images/Button/Disabled/Stop-All.gif'; 
idBounceSelBtn.src='images/Button/Disabled/Bounce-Selected.gif' 
idStartAllBtn.src='images/Button/Disabled/Start-All.gif'; 
idStopSelBtn.onclick="return false"; 
} 
+1

凡'disableButton'叫什麼名字?定時器在哪裏設置? – FakeRainBrigand

+1

@FakeRainBrigand在刷新函數之後。代碼就像 refresh(5); disableButton(); – user2644549

+1

爲什麼不能添加disableButton作爲刷新函數的最後一行? – closure

回答

2

您可能只需添加另一個參數(disable flag)即可達到所需的結果。

function refresh(nRefresh, disable) { 
    TimerSetting = document.all.curRefresh.Timer; 
    document.all.curRefresh.Timer = 'On'; 
    nTimeOut = nRefresh; 
    updateKnlButtons(); 
    psStatusUpdate(); 
    if (disable) disableButton(); 
} 
+0

非常感謝你的工作 – user2644549

0

您是否在尋找

function refresh(nRefresh, disableButton) { 
    TimerSetting = document.all.curRefresh.Timer; 
    document.all.curRefresh.Timer = 'On';  
    nTimeOut = nRefresh; 
    updateKnlButtons(); 
    psStatusUpdate(); 
    disableButton(); 
} 

function disableButton() { 
    idStopSelBtn.style.cursor='wait'; 
    idStartSelBtn.style.cursor='wait'; 
    idBounceRunningBtn.style.cursor='wait'; 
    idStopAllBtn.style.cursor='wait'; 
    idStartAllBtn.style.cursor='wait'; 
    idBounceSelBtn.style.cursor='wait' 
    idStopSelBtn.src='images/Button/Disabled/Stop-Selected.gif'; 
    idStartSelBtn.src='images/Button/Disabled/Start-Selected.gif'; 
    idBounceRunningBtn.src='images/Button/Disabled/Bounce-Running.gif'; 
    idStopAllBtn.src='images/Button/Disabled/Stop-All.gif'; 
    idBounceSelBtn.src='images/Button/Disabled/Bounce-Selected.gif' 
    idStartAllBtn.src='images/Button/Disabled/Start-All.gif'; 
    idStopSelBtn.onclick="return false"; 
} 

refresh(5, disableButton); 
相關問題