Disabling Safari autofill on usernames and passwords

后端 未结 17 1736
萌比男神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:25

    It seems the browser programmers think they know more than the website writers. While it's sometimes handy to allow the user to save passwords, there are other times when it's a security risk. For those times, this workaround might help:

    Start by using a conventional text input, instead of a 'password' type.

    Password:   
    

    Then - if you wish - set the focus to the input field.

    
    

    Put the JS at the end of the page.

    
    

    Now you have a conventional form field. What good is that?
    Change the CSS style for that input so it uses a font that is all 'bullets' instead of characters.

    
    

    Yes, you could 'tidy up' the code, and add .svg to it.

    Either way, the end result is indistinguishable from the 'real' password input, and the browser won't offer to save it.

    If you want the font, it's here. It was created with CorelDraw and converted with an online webfont conversion utility. (dot_webfont_kit.zip 19.3k)

    I hope this helps.

提交回复
热议问题