【发布时间】:2020-04-24 16:48:35
【问题描述】:
我创建了一个 html 页面,其中包含以下代码,我想要做的是将 json 元素映射到 data-site-key 的值,以等于对象 site-key 而不是“6LeoeSkTAAAAAA9rkZs5oS82l69OEYjKRZAiKdaF”。
config.json
{
"sitekey": "6LeWwRkUAAAAAOBsau7KpuC9AV-6J8mhw4AjC3Xz",
"bankPort": "8080"
}
HTML
<html>
<head>
<title>Captcha Harvester</title>
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<body>
<p id="output"></p>
</body>
</head>
<body>
<form action="/submit" method="POST">
<div class="g-recaptcha" id="captchaFrame" data-sitekey="6LeoeSkTAAAAAA9rkZs5oS82l69OEYjKRZAiKdaF" data-callback="sub"></div>
</form>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
const remote = require('electron').remote
const app = remote.app
const ipcRenderer = require('electron').ipcRenderer
function sub() {
ipcRenderer.send('sendCaptcha', grecaptcha.getResponse());
grecaptcha.reset();
}
</script>
</body>
</html>
【问题讨论】:
-
字符串化你的 json 配置,你可以将结果设置为你的
data-siteke属性 -
我该怎么做?
标签: javascript html node.js electron