Can one prevent Chrome causing an infinite loop when displaying alerts on the focus event, without disabling and re-enabling the event?

后端 未结 1 1083
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-13 15:27

Consider the following code. If I click in cmbMonkeys, it causes an infinite loop of alert messages in Google Chrome. My workaround for cmbPeople works fine. Does anyone

1条回答
  •  生来不讨喜
    2021-01-13 15:58

    With a simple state-handler, maybe?

    var isFocus = false;
    function cmbPeople_CallFocusHandler(control) {
        if(!focus){
            focus = true;
            cmbPeople_OnFocusHandler();
        }
    }
    
    function cmbPeople_CallBlurHandler(){
        isFocus = false;
    }
    

    0 讨论(0)
提交回复
热议问题