How do I have the cursor focus to a text field on page load?

Here I’m explaining how to focus cursor to a text field on page load. You can do this with several methods with a simple javascript code. For this, you have to put a name for your form and your text filed. See the sample form below.

<form name="myForm" method="post" action="">
      <input type="text" name="username" />
      <input type="submit" name="Submit" value="Submit" />

Now just look on the code. You can do this with a single line code within body onLoad.
<body onLoad="document.myForm.username.focus();">
You can call this code with a function like this:
  function curFocus(){
<body onLoad="curFocus();">

Another method is put the code inside the page after the form. See how is it.
<script type="text/javascript" language="JavaScript">
  var focusCtrl = document.forms["myForm"].elements["username"];
       if(focusCtrl) {

Share with Friends
[Facebook] [Jamespot] [Reddit] [StumbleUpon] [Twitter] [Email]

Download your free Feed Icons (Square Type)

I’m releasing a new free RSS/Feed icon set (Square Type). The set contains 10 icons which you can use for private and commercial projects, blogs and web-sites for free. The icons are available for as standard Mac or Windows icons as well as a handy PNG files. You can get it from here :

Share with Friends
[Facebook] [Jamespot] [Reddit] [StumbleUpon] [Twitter] [Email]

Free Desktop Calendar Wallpaper for January

Get your free calendar desktop wallaper for january.

These free wallpapers are for personal use on computer screens only. They may not be redistributed, offered for sale, included on CDs, or used for printed material. All the Wallpapers are licensed under a Creative Commons Attribution-No Derivative Works 2.5 India License.

Wallpaper : Sunset

Wallpaper : Kitty

Wallpaper : Ray of Lights

Wallpaper : Violet Flower

Wallpaper : Dark

Wallpaper : Kerala Landscape

Wallpaper : A Boat and a Crow

Wallpaper : Beach

Wallpaper : Grass-Hopper

Wallpaper : Young-One

Share with Friends
[Facebook] [Jamespot] [Reddit] [StumbleUpon] [Twitter] [Email]