我正试图找到一种方法来添加值在当前iframe提交和解决hCaptcha。
目前我可以使用以下命令获取iframe:
document.querySelector('[title="widget包含hCaptcha安全挑战的复选框"]')
由于没有id,但是我能够用上面提供的代码找到iframe。
然而,我无法找到一种方式,因为我不是一个JS编码输入值"data-hcaptcha-response"这是在我提交表单之前需要输入的iframe。
完整iframe代码:
<iframe src="xyz"
title="widget containing checkbox for hCaptcha security challenge"
tabindex="0" frameborder="0" scrolling="no" data-hcaptcha-widget-id="0zlooj2ooak"
data-hcaptcha-response="" style="width: 303px; height: 78px; overflow: hidden;"></iframe>
如果有人能指导我做这个项目,我将非常感激。
我想这应该可以完成工作:
let hcaptcha = document.querySelector('[title="widget containing checkbox for hCaptcha security challenge"]');
hcaptcha.dataset.hcaptchaResponse = "your_value_here";
你可以在这里了解更多关于在javascript中使用数据属性的信息。
我想你是在要求一个属性的集合值。试试这段代码,我想这会解决你的问题。
document
.querySelector('[title="widget containing checkbox for hCaptcha security challenge"]')
.setAttribute("data-hcaptcha-response", "value of hcaptcha");