Focusing (i-e putting cursor) appropriate control/HTML element in a webpage will enhance the user experience.
It should be done once after loading the page.
We can use the below javascript code for doing this on onload event of window.
This code should be placed inside the head tag.
<script type="text/javascript">
window.onload = function givefocus(){document.forms[0].elements[0].focus()}
</script>
Another way is we can do it on the onLoad event of body tag as below,
<body onLoad="document.frmname.name.focus();">
<form name="frmname" id="frmname" action="" method="post">
<input type="text" name="name">
</form>
</body>
More Articles...
Thursday, April 30, 2009
Popular Posts
- Software Testing Quiz Questions and Answers
- Javascript Quiz Questions and Answers
- MySQL Quiz Questions and Answers
- SEO Your Blog the Easy Way - Guest Post
- SEO (Search Engine Optimization) Quiz Questions and Answers.
- PHP Quiz Questions and Answers
- Basic Computer Hardware Quiz Questions and Answer.
- Use of tinyurl in Twitter
- HTML Quiz Questions and Answers
- General Knowledge Quiz Questions and Answers

No comments:
Post a Comment