Home » Scripts Alerts Script

Ask Visitor For Name Script


February 28, 2006

2.8/5.0 (43 votes total)


A very simple paste-it-in script that asks the vistor for his or her name when entering your page, then prints a "Hello" welcome message anywhere you wish in the body of the page.  If the visitor does not type in a message, a default message shows, instead. Very easy install for JavaScript newcomers.


Paste the following <script> ... </script> block into the
<body> (notice we said the body, *not* the <head>) of
your page, exactly where you would like the message to

Design Notes:

1.  When you use an in-the-body script like this, you will usually want to format the text it prints into the page.

This is simple enough to do -- just surround the the <script> ... </script> block with font tags, like this:

<font face="Arial" size="2" color="#FF0000">

Change the face, size, and color to match your design.

2.   You may not, of course, want to use the "Hello Name!" message we show.  See the two commented lines in the script above for where you can change the message.

JavaScript Functions:

Browsers Compatibility:

NS3-6, IE4-6

Add commentAdd comment (Comments: 0)  



Related Resources

Other Resources