Sayfa yüklendiğinde giriş kutusuna varsayılan odağı ayarlamaya çalışıyorum (örnek: google). Sayfam çok basit, ancak bunu nasıl yapacağımı anlayamıyorum. Bu gayet iyi çalışıyor ikenOdağı bir HTML giriş kutusuna odaklama sayfa yükleme
<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>
Nasıl bu işe yaramazsa gelir:
Bu defa var nedir?
<input type="password" name="PasswordInput"/>
şöyle bir id niteliği, sahip olmalıdır:
<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>
Yardım çok Bu hat
“tüm güncel tarayıcılarda çalışır” - yani gerçekten "tüm geçerli tarayıcılar" tanımınıza bağlıdır. –
ie9: http://stackoverflow.com/questions/8280988/how-to-make-input-autofocus-in-internet-explorer – jedierikb
@BhaveshGangani ['autofocus' Internet Explorer 9 ve önceki sürümlerinde desteklenmez.] (http://www.w3schools.com/tags/att_input_autofocus.asp) –