因此,我搜索了一段时间,以查看是否可以禁用黄色bg chrome添加到它记得的字段中...这对我的主题有些烦人。

我找到了可以解决此问题的代码!

<script type="text/javascript">
  $(function() {
    if (navigator.userAgent.toLowerCase().indexOf("chrome") >= 0) {
    var intervalId = 0;
      $(window).load(function() {
        intervalId = setInterval(function () { // << somehow  this does the trick!
          if ($('input:-webkit-autofill').length > 0) {
            clearInterval(intervalId);
            $('input:-webkit-autofill').each(function () {
              var text = $(this).val();
              var name = $(this).attr('name');
          $(this).after(this.outerHTML).remove();
          $('input[name=' + name + ']').val(text);
            });
          }
        }, 1);
      });
    }
  });
</script>


问题是尝试时会出现黄色的闪烁现象

这也是我的表格。

<form action="login.php" method="post" class="form-container">

  <input class="menu_button" type="submit" value="Login">
  <a href="register.php" class="menu_button">Register</a><br>

  <input autocomplete="off" class="form-field" value="Username" type="text" name="username"   onfocus="if (this.value=='Username') this.value='';"/><br />
  <input class="form-field" value="Password" type="password" name="password" onfocus="if   (this.value=='Password') this.value='';"/><br />

</form>


这仅仅是因为Chrome出现故障或类似问题吗?

是否有可能解决?

最佳答案

您可以使用CSS隐藏元素

/* may as well target Chrome (catches Safari too tho) */
@media screen and (-webkit-min-device-pixel-ratio:0){
    input{
        opacity:0;
    }
}


然后在webkit业务启动后向他们展示。

$('input').css({opacity:1});


是的,它们在加载时将是不可见的,但实际上应该不会引起注意。

10-05 20:58
查看更多