<html>
<body>
<form id="myForm" action="demo_keygen.php" method="get">
Username: <input type="text" name="usr_name">
Encryption: <keygen id="myKeygen" name="security">
<input type="submit">
</keygen></form>
<p>点击 "点我" 按钮返回 keygen 字段所属表单的id。</p>
<p id="demo"></p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction()
{
var x = document.getElementById("myKeygen").form.id;
document.getElementById("demo").innerHTML=x;
}
</script>
</body>
</html>