Consider the following code. If I press cmbMonkeys, it causes an endless loop of warning messages in Google Chrome. My workaround for cmbPeople is working fine. Does anyone know of a different way to prevent endless loops when displaying warnings about focus or blur events without disabling and re-enabling the event?
<html> <head> <script> var eventHandler; function cmbPeople_OnFocusHandler() { alert("focus"); } function cmbPeople_CallFocusHandler(control) { eventHandler = control.onfocus; control.onfocus = null; cmbPeople_OnFocusHandler(); } function cmbPeople_CallBlurHandler(control) { control.onfocus = eventHandler; } function cmbMonkeys_FocusHandler(control) { alert("I like monkeys"); } </script> </head> <body> monkeys <select id="cmbMonkeys" onfocus="cmbMonkeys_FocusHandler(this)"></select> people <select id="cmbPeople" onfocus="cmbPeople_CallFocusHandler(this)" onblur="cmbPeople_CallBlurHandler(this)"></select> </body> </html>
source share