当前位置:文档之家› 【IT专家】将焦点放在页面加载的HTML输入框上

【IT专家】将焦点放在页面加载的HTML输入框上

本文由我司收集整编,推荐下载,如有疑问,请与我司联系
将焦点放在页面加载的HTML输入框上
将焦点放在页面加载的HTML输入框上[英]Setting focus on an HTML input box on page load I’m trying to set the default focus on an input box when the page loads (example: google). My page is very simple, yet I can’t figure out how to do this.
 当页面加载时(例如:谷歌),我试图在输入框上设置默认焦点。

我的页面很简单,但我想不出怎么做。

This is what I’ve got so far:
 这就是我到目前为止得到的:
 html head title Password Protected Page /title script type=“text/javascript” function FocusOnInput() document.getElementById(“PasswordInput”).focus(); /script style type=“text/css” media=“screen” body, html {height: 100%; padding: 0px; margin: 0px;} #outer {width: 100%; height: 100%; overflow: visible; padding: 0px; margin: 0px;} #middle {vertical-align: middle} #centered {width: 280px; margin-left: auto; margin-right: auto; text-align:center;} /style /head body onload=“FocusOnInput()” table id=“outer” cellpadding=“0” cellspacing=“0” tr td id=“middle” div id=“centered” form action=“verify.php” method=“post” input type=“password” name=“PasswordInput”/ /form /div /td /tr /table /body /html How come that doesn’t work while this works fine?
 为什么这样不行呢?
 html head script type=“text/javascript” function FocusOnInput() document.getElementById(“InputID”).focus(); /script /head body onload=“FocusOnInput()” form input type=“text” id=“InputID” /form /body /html Help is much appreciated :-)
 非常感谢您的帮助:
 应该有一个id属性,如下所示:
 input type=“password” name=“PasswordInput” id=“PasswordInput”/ 279。

相关主题