简体   繁体   中英

Field shown as autofilled by browser, is blank when accessed with js

I have a login form which gets auto-filled with username and password by the browser. On chrome I am seeing this issue where - the password field is shown as autofilled in the browser, but when I access its value through javascript, it is blank.

Has anyone hit this issue?

The values are most likely being filled out by Chrome after the page has been completely rendered. I can't tell how or when you are trying to fetch the values through your javascript but if you do it without letting the full page load you will not get any results. Try using the Window.onload -event at the bottom of the body to access the field.

Example:

   <script>
   //call after page loaded
   window.onload=getPasswordFunc; 
   </script>
</body>

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