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...
Shop at Rajamanickam.com | Birthday Gift Idea? | Hire me for $6 per Hour
Get 3 useful ebooks for Rs 99 in India and $5.99 globally
Get a 75% commission | ChatGPT and and Google Gemini for Beginners (Use Discount code QPT)
Thursday, April 30, 2009
Search This Blog
Art of Talking to AI | Tech eBook | Dream Big | Listen to Dream Big
Today's Deals | Timesheet | Products | 3 ebooks for $5.99 / Rs 99 | Earn 50% commission
About | Privacy | Follow | TOS | WhatsApp | Contact
I may earn a commission from Amazon affiliate links
Today's Deals | Timesheet | Products | 3 ebooks for $5.99 / Rs 99 | Earn 50% commission
About | Privacy | Follow | TOS | WhatsApp | Contact
I may earn a commission from Amazon affiliate links
No comments:
Post a Comment