Pages

Thursday 6 February 2014

Calling a JavaScript function on page load.

Hi,

This example explains you how to Focus cursor on Username text filed on page load.

When the page has loaded the function named Focus() will be called and cursor will focus on Username field.

Source Code for the example.

<html>
<head>
<script type="text/javascript">
function Focus(){
document.getElementById("name").focus();
return true;
}
</script>
</head>

<body onload="return Focus()";>
<table>
<tr>
<td>UserName:</td>
<td><input type="text" name="name" id="name"/></td>
</tr>
<tr> <td>Password:</td>
<td><input type="password" name="pwd" id="pwd" /></td>
</tr>
<tr><td></td>  <td> <input type="submit" value="Submit"/></td></tr>
</table>
</body>
</html>

No comments:

Post a Comment