|
Script Introduction
This script will prompt the viewer for a name and then write the name on the Web page.
Cut and Paste Code: HEAD Section
This code should be placed between the <head> and </head> tags.
Cut and Paste Code: BODY Section
This code should be placed between the <body> and </body> tags.
Installation Instructions
-
Paste the HEAD Section code from above between the <head> and </head> tags on your page.
-
Paste the BODY Section code from above between the <body> and </body> tags on your page,
exactly where you want the greeting to appear.
-
Find the matching lines below in the script and change the text in red to
the text you wish to use:
var yourname= prompt('Please enter your name:','');
yourname="Dude"; //sets a default name if nothing is entered
document.write("Hello, "+yourname+"! Welcome to My Page!");
-
Check the Format Window
to be sure you do not have one single line of code, or too many line breaks in the code.
Example
A working sample of the script is shown below.
Click the link to open a new page and test the script.
Example Link
|