简体   繁体   中英

Onclick event for input field doesn't work while accessibility screen reader is running

Onclick event for input field doesn't work while accessibility screen reader is running.

I use this HTML example for many years. But since Android 8, it doesn't work. Until Android 8, the onclick event was triggered by a double-tap action while the screen reader is running.

<input type="text" name="pwd1" id="pwd1" onclick="alert('test');" />

I want it to work as before Android 8. I want the onclick event for a div to act as a double tap. But since Android 8, it doesn't work.

Using onclick on an input text field is anyway a bad practice. You should probably use onfocus instead.

Reasons why you shouldn't use onclick include:

  • It isn't triggered when the field is focused using the keyboard or anything other than the mouse
  • It may be triggered even if the field is already in focus, for example when selecting or moving the insertion point

You probably want to do something when the field gets the focus, not when the field is clicked; in that case, use onfocus.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM