iNET Interactive - Online Advertising Agency
          
   Home    Authors    About    Login    Contact Us
   Search:   
Advanced Search     
  Articles

  ASP (26)
  ASP.NET (19)
  C and C++ (4)
  CFML (2)
  CGI and Perl (16)
  Flash (2)
  Java (7)
  JavaScript (28)
  PHP (92)
  MySQL (13)
  MSSQL (3)
  HTML (34)
  SEO (9)
  Visual Basic (12)
  CSS (13)
  SSI (5)
  XML (12)
  C# (14)

  Developer News

May 11, 2008
Improving accessibility for motor impaired users
WebDevTips UK
 
May 11, 2008
10 ways to orientate users on your site
WebDevTips UK
 
May 11, 2008
Web Design Clinic - Rros restoration camp 2006
About
 
May 10, 2008
The Moods of Facebook
About
 
May 9, 2008
CSS 1 properties are a great start
About
 
May 9, 2008
Reader Question: How do you get fancy fonts?
About
 
Courtesy of moreover.com
 
Want to receive new articles via e-mail? Click here!
/Home /JavaScript

Interacting with your users with javascript generated messages 

  Views:    3069
  Votes:    1
by Diego Botello 12/15/03 Rating: 

Synopsis:

Javascript lets you interact with your user with messages. This messages can be alert, confirm, and prompt boxes.
Pages: 
The Article

Alert boxes

This boxes alert users about something that you want them to know. The following example produces an alert box.

alert("Good Morning");

This will pop a window with the message "Good Morning". If you want to add several lines to the message you can separate each line with the \n (new line character).

Confirm boxes

Confirm boxes gives the user two options, and depending on what the user chose you can take an action. For example the code bellow ask the user if he/she want to continue to the site. If the answer is yes then an alert box shows "Welcome", if it's no then "Good Bye". Of course you can change those answers to whatever you want, for example you can redirect the user to a site depending on the answer.

<script>
var conf=confirm("Do you want to continue to my site?")
if (conf)
alert("Welcome")
else
alert("Good Bye")
</script>
 

Prompt boxes

Prompt boxes are used to give the user the opportunity to enter some information. The bellow example asks the user for his/her name. The information given by the user is stored in the variable user. It can be used later for any purposes. In this example we made an alert box to welcome the user.

<script>
var user=prompt("What is your name?")
alert("Welcome "+user)
</script>

Pages: 



 
  Sponsors