<html>
<body>
<form 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字段的 name 属性值。</p>
<button onclick="display()">显示 name 属性值</button>
<button onclick="change()">修改 name 属性值</button>
<script>
function display()
{
var x = document.getElementById("myKeygen").name;
alert("keygen 字段的名称为: " + x);
}
function change()
{
var x = document.getElementById("myKeygen").name="newName";
alert ("名称被修改为: " + x);
}
</script>
</body>
</html>