0

We are currently in the process of maintenance for IE11 in the service.

  1. There are two forms that raise an alert on focusout.
  2. In this case, let's call the two forms A_form and B_form.
  3. After clicking A_form, select B_form.
  4. At this time, focusout occurs in A_form and an alert is raised.
  5. After clicking OK on the alert, click a_form.
  6. (Error) If there are multiple windows in the window, the window with the form is pushed back.

I am in the same situation as above. Why are you doing this? Any help would be appreciated. Thank. I didn't speak English well, so I used a translator. Please understand the clumsy context. It only happens in IE11. I tested firefox, chrome and edge.

My development environment is as follows : windows10, IE11 The sample code below is attached.

function A_alert() {
    alert("a_form alert");
}

function B_alert() {
    alert("b_form alert");
}
<input id="a_form" type="text" onfocusout="A_alert()">
<input id="b_form" type="password" onfocusout="B_alert()">

console.log():

a_form : mouse down
a_form : focus
a_form : mouse up
a_form : click
b_form : mouse down
a_form : focus out
b_form : mouse up
a_alert : ok
a_form : blur
b_form : focus
b_form : focus out
b_alert :raised error
5
  • Warning: The Stack Snippet will put you in an endless alert loop on Chromium-based browsers (as of this writing). Commented Apr 1, 2022 at 9:06
  • alert on focusout is a fundamental no-no. alert and focus interact in unfortunate ways that vary from browser to browser, and alert is horrible user experience. The solution here is to not use alert for whatever you're trying to tell the users. (Before you say [as people often do] "But it's the requirement" -- too bad. :-D Tell the person making the requirements it's not feasible and maintainable.) Commented Apr 1, 2022 at 9:08
  • I agree with the comments above. The behavior looks like by design in IE. As IE desktop app will retire soon, so this won't be fixed. I suggest that you can use other code like console.log instead of alert.
    – Yu Zhou
    Commented Apr 4, 2022 at 5:36
  • Thanks to everyone who responded. Unfortunately, this is a requirement that should work in all browsers. But the dead line came without finding a solution. I decided not to apply it to IE.
    – kmkimmm
    Commented Apr 5, 2022 at 14:32
  • Additionally, in Chromium-based browsers, an alert is triggered only when document.activeElement is null. This avoids endless alert loops.
    – kmkimmm
    Commented Apr 5, 2022 at 14:36

1 Answer 1

0
<form>
   <input id="a_form" type="text" onfocusout="A_alert()" />
   <input id="b_form" type="password" onfocusout="B_alert()" />
</form>

wrap by form in IE

1
  • thank you. However, this did not solve the problem.
    – kmkimmm
    Commented Apr 5, 2022 at 14:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.