<!-- JavaScript:Extras code snippet 12. -->
<!-- Using the 'window.onload' global event handler instead 
of the <body> 'onload' attribute. -->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- Code source: http://www.justfigures.co.uk/ -->
<!-- A resource for web developers using XHTML, CSS, JavaScript, PHP -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>View code snippet page</title>
<script language="JavaScript" type="text/javascript">
//<![CDATA[
function giveFocus() {
//gives focus to the text1 field
        theForm.text1.focus()
        return true
	}
//]]>
</script>
</head>

<body>
<!-- The 'window.onload' global event handler can be placed
in the main section of the page -->
<script type="text/javascript">
//calls the function 'giveFocus'
window.onload = giveFocus;
</script>

<form name="theForm" id="theform" method="post" action="">
<textarea name="text1" rows="10" cols="30">
</textarea>
<br/>
<input type="submit" value="Send"/>
</form>
</body>
</html>