Chrome Autofill/Autocomplete no value for password

后端 未结 20 1967
逝去的感伤
逝去的感伤 2020-11-27 02:57

When you have saved username and password for some site Chrome will autofill that username and password, but if you try to get the value for the password input field it is e

20条回答
  •  日久生厌
    2020-11-27 03:11

    Just wrote an angular directive related to this. Ended up with the following code:

    if ('password' == $attrs.type) {
          const _interval = $interval(() => { //interval required, chrome takes some time to autofill
              if ($element.is(':-webkit-autofill')) { //jQuery.is()
                  //your code
                  $interval.cancel(_interval);
              }
          }, 500, 10); //0.5s, 10 times
    }
    

    ps: it wont detect 100% of the times, chrome might take longer than 5 seconds to fill the input.

提交回复
热议问题