How do I disable the save password bubble in chrome using Javascript?

前端 未结 13 1939
不思量自难忘°
不思量自难忘° 2020-11-27 19:56

I need to be able to prevent the Save Password bubble from even showing up after a user logs in.

Autocomplete=off is not the answer.

I have not come across a

13条回答
  •  温柔的废话
    2020-11-27 20:32

    I found no alternative with all the benefits I need so, created a new one.

    HTML

    
    

    jQuery (replace with vanilla JS with same logic if you don't use jQuery)

    $('.js-text-to-password-onedit').focus(function(){
        el = $(this);
        el.keydown(function(e){
          if(el.prop('type')=='text'){
            el.prop('type', 'password');
          }
        });
        // This should prevent saving prompt, but it already doesn't happen. Uncomment if nescessary.
        //$(el[0].form).submit(function(){
        //  el.prop('readonly', true);
        //});
    });
    

    Benefits:

    • Does not trigger prompt
    • Does not trigger auto fill (not on page load, nor on type change)
    • Only affects inputs that are actually used (allowing undisturbed element cloning/templating in complex environments)
    • Selector by class
    • Simple and reliable (no new elements, keeps attached js events, if any)
    • Tested and works on latest Chrome 61, Firefox 55 and IE11 as of today

提交回复
热议问题