Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1711 How can set the focus in a form field in a absolutelty positioned layer?

You are here: irt.org | FAQ | JavaScript | DHTML | Q1711 [ previous next ]

Try:

<html>

<head>

<script language="JavaScript"><!--
function start() {
  if (document.getElementById) {
    document.getElementById('focusRequired').focus();
  }
  else if (document.all) {
    document.all['focusRequired'].focus();
  }
  else if (document.layers) {
    document.layers['myLayer'].document.forms['myForm'].elements['myText'].focus();
    // or
    document.myLayer.document.myForm.myText.focus();
    // or
    document.layers[0].document.forms[0].elements[0].focus();
  }
}
//--></script>

</head>

<body onLoad="start()">

<layer name="myLayer" style="postion:absolute">
<form name="myForm">
<input type="text" name="myText" id="focusRequired">
</form>
</layer>

</body>

</body>

</html>

©2018 Martin Webb