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
Search This Blog
AI Course | Bundle Offer | Unlocking AI | Dream Big | Listen to Dream Big
Today's Deals | Timesheet | Products | SQL ebook | Earn 50% commission
About | Privacy | Follow | TOS | WhatsApp | Contact
I may earn a commission from Amazon affiliate links
Today's Deals | Timesheet | Products | SQL ebook | Earn 50% commission
About | Privacy | Follow | TOS | WhatsApp | Contact
I may earn a commission from Amazon affiliate links
No comments:
Post a Comment