Javascript 使用focus 设置文本框焦点
Javascript 使用focus 设置文本框焦点The javascript code below shows how to set the focus on an Input Field / Form Field / Html Element (Textbox) when the page is loaded.<html>
<head>
<script type="text/javascript">
function setFocus()
{
document.getElementById("name").focus();
}
</script>
</head>
<body onload="setFocus()">
<form>
Name: <input type="text" id="name" size="30"><br />
Surname: <input type="text" id="surname" size="30">
</form>
</body>
</html>
页:
[1]