简体   繁体   English

如何阻止 Chrome 请求保存信用卡信息

[英]How to prevent Chrome from requesting to save credit card information

I am trying to find a way to programmatically disable Chrome's "Do you want save this credit card info" prompt.我正在尝试找到一种方法来以编程方式禁用 Chrome 的“是否要保存此信用卡信息”提示。

I have tried adding autocomplete="off" to all the inputs as well as the form, yet this prompt still comes up.我曾尝试将autocomplete="off"添加到所有输入以及表单中,但仍然出现此提示。

Is there a way to disable this programmatically?有没有办法以编程方式禁用它?

Unfortunately, this is different from Disable browser 'Save Password' functionality because this all revolves around tricking Chrome into thinking the input field is not a password field / simply using autocomplete="off" , however Chrome no longer acknowledges autocomplete="off" .不幸的是,这与禁用浏览器的“保存密码”功能不同,因为这一切都围绕着诱使 Chrome 认为输入字段不是密码字段/只是使用autocomplete="off" ,但是 Chrome 不再承认autocomplete="off"

This is the banner I'm referring to:这是我所指的横幅:

你想让 chrome 保存你的信用卡信息吗

我所做的是使用信用卡号的隐藏字段并在其中保存实际的信用卡号,然后通过 JScript 从屏幕上清除实际的信用卡号。

I had the same problem you're experiencing;我遇到了与您相同的问题; and with a newer browser version.并使用更新的浏览器版本。

存卡提示

To resolve this, you have to set autocomplete at form element.要解决此问题,您必须在表单元素上设置自动完成功能。

<form autocomplete="off" action="/cc.html" method="POST">
    <!-- Form fields -->
    <input type="text" name="cc" id="cc" />
    <!-- More form fields -->
</form>

For some reason Google Chrome ignores the autocomplete="off" at <input type="text" /> for Credit Card prompts, but doesn't prompt when you set it with <form> .出于某种原因,谷歌浏览器会忽略<input type="text" />信用卡提示处的autocomplete="off" ,但在您使用<form>设置时不会提示。

I tried everything and had no success.我尝试了一切,但没有成功。 The way I solved it, in the end, was actually to replace my label eg "Credit Card Number" with an image that contained the words "Credit Card Number", it worked a charm.最后,我解决它的方法实际上是用包含“信用卡号”字样的图像替换我的标签,例如“信用卡号”,它很有魅力。

<div class="field">
   <div class="label">
      <img src="../images/cc-number.png">
   </div>
   <div class="value">
      <input type="text" name="ccnumber" id="ccnumber">
   </div>
</div>

There's a good reason why Chrome ignores autocomplete="off" - it's not your information to decide whether or not the user's browser can save it. Chrome 忽略autocomplete="off"是有充分理由的 - 决定用户的浏览器是否可以保存它不是您的信息。 As such there is deliberately no way to disable this functionality programmatically.因此,故意无法以编程方式禁用此功能。

You can make Chrome respect autocomplete="off" by setting the appropriate flag in chrome://flags which would give you the outcome you desire, but this only affects your browser - again, it's the user's information to decide to do with as they see fit.可以通过在chrome://flags设置适当的标志让 Chrome 尊重autocomplete="off" ,这会给您带来您想要的结果,但这只会影响您的浏览器 - 同样,决定如何处理是用户的信息觉得合适。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM