我正在使用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