Detecting Browser Autofill

前端 未结 29 1456
天涯浪人
天涯浪人 2020-11-22 06:15

How do you tell if a browser has auto filled a text-box? Especially with username & password boxes that autofill around page load.

My first question is when does

29条回答
  •  太阳男子
    2020-11-22 06:37

    In Chrome and Edge (2020) checking for :-webkit-autofill will tell you that the inputs have been filled. However, until the user interacts with the page in some way, your JavaScript cannot get the values in the inputs.

    Using $('x').focus() and $('x').blur() or triggering a mouse event in code don't help.

    See https://stackoverflow.com/a/35783761/32429

提交回复
热议问题