我正在使用SSO将html表单文章重定向到网站。用户名直接从注册表中获取。但是,我不确定为什么该值无法插入到表单值中。有人可以请指教。非常感激。如何从函数向HTML表单插入返回变量
<html>
<head>
<body>
<script>
var username;
var test;
function submitForm() {
document.forms["ciqForm"].submit();
}
function getUsername() {
var WshShell = new ActiveXObject("WScript.Shell");
username = WshShell.RegRead("HKEY_CURRENT_USER\\Software\\Plugin\\username");
// username = "[email protected]"
return username;
}
// document.getElementbyName('extRedirUserName').value=getUsername();
document.forms['myForm'].elements['extRedirUserName'].value=getUsername();
</script>
<body onload="submitForm()">
<h1>Redirecting.</h1>
<form id="myForm" name="myForm" method="POST" action="https://www.somewebsite.com">
<input type="hidden" id="hello" name="extRedirUserName" value="" />
<input type="hidden" name="extRedirPassword" value= "password" />
</form>
</body>
</head>
`
您提交上负载的形式,'<身体的onload = “submitForm()”>' – Ramanlfc