Tag Archives: Javascript

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]

Javascript Reference – Alert();

Alert() is a methord of the window object. Its display popup boxes with messages(‘Texts’) with OK button.
Usage: alert("Hai Guest");

How to write text with multiple lines in an alert box?

Alert is a mathord of window object. So its can’t read HTML tags. Some commonly used escapes characters listed below:
\n : It inserts a new line
\t : tab
\r : Carriage return
\b : backspace
\f : form feed
\' : Single Quote
\" : Double Quote
\\ : Backslash

Usage: alert("Hai User\n Welcome to My website");
Click here to see the alert mentioned above.

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

CSS Tab-Based Navigation Scripts

Css Tab Menu
Css Tab Menus

Tab navigation has been one of the most important element in web layouts. Visitors can properly navigate through the website with a tabbed navigation. A tab navigation should help visitors to easily understand where they should be clicking. Here I have compiled a mass list of nice and sleek CSS Tab based navigation samples you can integrate on your site.

Continue reading CSS Tab-Based Navigation Scripts

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