让光标定位在网页指定的输入文本框里

来源:互联网 发布:caffe中的xavier 编辑:程序博客网 时间:2024/05/06 11:35

<script>
function aa(){
document.getElementById("comment").focus();
scroll(0,0);
}
</script> 1.把此代码加入到</head>之上

2.把原有的<body>改成:<body onload="aa()">

例:<input type="text" name="username" style="width:160px;" id="comment">

3.找到你需要定位某输入框代码里添加id="comment"