Table: WebNotes
User: dreamable
Created at: 2021-01-29 12:16:11 UTC
Updated at: 2021-01-29 12:16:11 UTC
Reference:(Table ID 25, Record ID 2)

标题 :
onblur infinite loop issue in Safari
笔记 :

问题: onblur触发alter,然后在safari下死循环

根源:Root Cause: Each time clicking on 'Ok' button of the alert, onblur happens and we are trapped in an infinite loop.

解决

        alert('wrong !!!');
        setTimeout(function(){
            field.focus();
        },0);

注意必须使用setTimeout,直接focus不能work。设置field.value为空不是必须的。

遗留问题:如果用tab转到下一个form field,也有onblur事件,还是死循环。

解决方法:如果value是空,则忽略,不触发alter

更多讨论:1, 2

Tag: