Mic*_*sca 5 html forms google-chrome
我想知道是否有办法显示关键变量的值?没有对答案的检查,我一生都无法找到答案。请帮忙:
<form method="post" action="/webwork2//Section13.3/5/"
enctype="multipart/form-data" id="problemMainForm" name="problemMainForm" onsubmit="submitAction()">
<input type="hidden" name="user" value="name" id="hidden_user" />
<input type="hidden" name="effectiveUser" value="name" id="hidden_effectiveUser" />
<input type="hidden" name="key" value="ZHaiEU4qkcpMc1m2kBaYrMvbOo5TktAY" id="hidden_key" />
</form>Run Code Online (Sandbox Code Playgroud)
这个简单的JavaScripthidden函数使网站上的所有输入都可见:
function showHiddenInputs() {
inputs = Array.from(document.getElementsByTagName('input'));
inputs.forEach((input) => {
if (input.type === 'hidden')
input.type = 'text';
})}
showHiddenInputs();
Run Code Online (Sandbox Code Playgroud)
浏览器控制台的一行代码:
inputs = Array.from(document.getElementsByTagName('input')); inputs.forEach((input) => { if (input.type === 'hidden') input.type = 'text'; })
Run Code Online (Sandbox Code Playgroud)
如果您只想从名称为“key”的元素获取值,请在控制台中使用:
document.getElementsByName('key')[0].value
Run Code Online (Sandbox Code Playgroud)
如果有多个名为“key”的元素,您可以使用任何其他数字而不是 0,或者您可以使用此循环:
elements = Array.from(document.getElementsByName('lsd'));
elements.forEach((element) => {
if (element.type === 'hidden')
console.log(element.value);
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10357 次 |
| 最近记录: |