0

我有刷新功能

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

此功能重新加载页面。单击按钮后,我给 refresh(5) 以在 5 秒后刷新页面。由于某种原因,我想在刷新函数完成后触发一个函数,但是在刷新函数完成之前这个函数被触发。如何确保在刷新函数完成后调用禁用函数

 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";
}
4

2 回答 2

2

您可能只需添加另一个参数 ( disable flag) 即可获得所需的结果。

function refresh(nRefresh, disable) {
  TimerSetting = document.all.curRefresh.Timer;
  document.all.curRefresh.Timer = 'On';
  nTimeOut = nRefresh;
  updateKnlButtons();
  psStatusUpdate();
  if (disable) disableButton();
}
于 2013-08-07T06:39:18.543 回答
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);
于 2013-08-07T06:47:03.003 回答