获取JSON之前的JavaScript登录
我在获取JSON之前的JavaScript登录,javascript,html,ecmascript-6,Javascript,Html,Ecmascript 6,我在/json <form action="/json" method="post"> <input class="form-control" type="password" name="password" id="ps" placeholder="Password" required> <input class="btn btn-outline-danger" type="su
/json
<form action="/json" method="post">
<input class="form-control" type="password" name="password" id="ps" placeholder="Password" required>
<input class="btn btn-outline-danger" type="submit" value="ENTER" id="ab">
</form>
如何做到这一点
我可以在chrome控制台上用
document.getElementById('ps').value = 'test'
document.getElementById('ab').click()
您需要定义
onsubmit
值,如
<form action="/json" method="post" onsubmit="document.getElementById('ps').value = 'test';">
<input class="form-control" type="password" name="password" id="ps" placeholder="Password" required>
<input class="btn btn-outline-danger" type="submit" value="ENTER" id="ab">
</form>
并在onsubmit
中调用:
<form action="/json" method="post" onsubmit="beforeSubmit();">
<input class="form-control" type="password" name="password" id="ps" placeholder="Password" required>
<input class="btn btn-outline-danger" type="submit" value="ENTER" id="ab">
</form>
您需要定义提交时的
值,如
<form action="/json" method="post" onsubmit="document.getElementById('ps').value = 'test';">
<input class="form-control" type="password" name="password" id="ps" placeholder="Password" required>
<input class="btn btn-outline-danger" type="submit" value="ENTER" id="ab">
</form>
并在onsubmit
中调用:
<form action="/json" method="post" onsubmit="beforeSubmit();">
<input class="form-control" type="password" name="password" id="ps" placeholder="Password" required>
<input class="btn btn-outline-danger" type="submit" value="ENTER" id="ab">
</form>
只需使用密码发送POST
fetch('/json', {
method: 'POST',
body: new URLSearchParams("password=test")
})
.then(res => res.json())
.then((out) => {
document.getElementsByTagName('textarea')[0].innerHTML = out.Proxies.join("\n");
})
.catch(err => { throw err; });
只需使用密码发送POST
fetch('/json', {
method: 'POST',
body: new URLSearchParams("password=test")
})
.then(res => res.json())
.then((out) => {
document.getElementsByTagName('textarea')[0].innerHTML = out.Proxies.join("\n");
})
.catch(err => { throw err; });
如何绑定表单元素上的submit事件并将抓取作为回调传递给事件处理程序?如何绑定表单元素上的submit事件并将抓取作为回调传递给事件处理程序?