Disabling Safari autofill on usernames and passwords

后端 未结 17 1737
萌比男神i
萌比男神i 2020-11-29 03:52

You might already know, that Safari has a nasty autofill bug where it fills email, username and password fields no matter if you set autocomplete=\"off\" or not

17条回答
  •  爱一瞬间的悲伤
    2020-11-29 04:20

    This question has already been successfully answered, but as of today's date, the solution didn't work for me without making some oddly particular changes - so I'm noting it here as much for my own reference if I decide to come back to it as for everyone else's.

    • The fake input needs to be after the real email input in the dom.
    • The fake input requires a fake label.
    • The fake label cannot be absolutely positioned.
    • Can't use display, visibility or opacity to hide the fake elements.

    The only solution I found was to clip the visibility of the fake elements with overflow: hidden.

    
    
    
    
    
    

    For the record, the particular case this hack came in useful for was one where an admin is editing the profile of other users and Safari was replacing the email of the user with the email of the admin. We've decided that for the small (but frustrating) amount of support requests that this Safari 'feature' creates, it's not worth maintaining a hack that seems to need to evolve as Safari tightens up on it, and instead provide support to those users on how to turn off autofill.

提交回复
热议问题