简体   繁体   English

使用 Braintree 的托管字段加载表单时,如何使浏览器专注于长信用卡号字段

[英]How can I make browser focus on the long credit card number field when loading a form using Braintree's Hosted Fields

I'm using BrainTree Hosted Fields我正在使用 BrainTree 托管字段

https://developers.braintreepayments.com/guides/hosted-fields/overview/javascript/v3 https://developers.braintreepayments.com/guides/hosted-fields/overview/javascript/v3

For a payment gateway.对于支付网关。

When the Credit Card form is loaded, the user has to click into the input to begin.加载信用卡表单后,用户必须单击输入才能开始。

My Client wants the Input box for the long card number to already be in focus.我的客户希望长卡号的输入框已经成为焦点。 I can't work out how to do this as the form is in an iFrame for security reasons, and the number of options in the documentation don't seem to cover setting a textarea as in focus.我无法弄清楚如何执行此操作,因为出于安全原因,表单位于 iFrame 中,并且文档中的选项数量似乎并未涵盖将 textarea 设置为焦点。

Am I missing something here, or is this simply not possible?我在这里遗漏了什么,或者这根本不可能?

What you're asking for isn't possible for arbitrary 3rd-party iframes, but Braintree's API does appear to allow it by using the focus() method on the hostedFieldInstance:您所要求的对于任意 3rd 方 iframe 是不可能的,但 Braintree 的 API 似乎确实允许通过在托管字段实例上使用focus() 方法来实现:

hostedFieldsInstance.focus('fieldname', function (focusErr) {
  if (focusErr) {
    console.error(focusErr);
  }
});

When dealing with iFrames that is the problem.在处理 iFrame 时,这就是问题所在。 You can focus the iFrame manually, even with or without delay but if the iFrame provider didn't developed the form to get focus on that element and does not provide a postMessage API, then you are basically out of options because it is outside your sec sandbox.您可以手动聚焦 iFrame,即使有延迟或没有延迟,但如果 iFrame 提供者没有开发表单来聚焦该元素并且不提供 postMessage API,那么您基本上没有选择,因为它在您的范围之外沙箱。 If this was possible basically browser security will be compromised.如果这是可能的,基本上浏览器的安全性将受到损害。

Closing Question as this isn't possible.结束问题,因为这是不可能的。

All "solutions" err on the side of trying to undermine the security of the customer's card details.所有“解决方案”都试图破坏客户卡详细信息的安全性。

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

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