Friday, February 23, 2024
 Popular · Latest · Hot · Upcoming
rated 0 times [  4] [ 2]  / answers: 1 / hits: 8063  / 4 Years ago, thu, april 16, 2020, 12:00:00

I have simple button like that:

<button class=emoji-button-container onblur=APP.hideEmojiContainer() onclick=APP.toggleEmojiContainer()>

On Chrome both event works perfectly.

On Safari onclick event works without any problem, but onblur event doesn't get triggered. Also element.blur() function doesn't trigger onblur event.
I need it to work on Safari just like on Chrome, so what can I do? what's problem here?

More From » html


It seems Safari doesn't focus button element on click. So, according to definition, onblur attribute fires the moment that the element loses focus. Element is not focused => onblur doesn't fire.

One of the solution could be manually apply button.focus() after click.

Another one is to attach click event on document as here

[#4134] Tuesday, April 14, 2020, 4 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.

Total Points: 406
Total Questions: 104
Total Answers: 121

Location: Iceland
Member since Tue, Jan 25, 2022
2 Years ago
marvinm questions