The first thing you must know is where to place it in your page.
It is not necessary but recommended because certain
browsers require it to be right after the </title> and
before the <head> tag.
Scripts will be placed through out a page on further pages. I have a script down by my guestbooks. Functions wich are described later on should always be up in the head.
Now for the actual beginning of the script.
Now for the entire script.
alert("Welcome to my page");
// End Script -->
You can also place some comments that would not be seen unless the source code is being viewed.
one line comments
// comments not longer than on line
/* comments as long as you want
like credits. script written by
Permission to use if you
sell you soul etc
Making it more interactive
Now you know how to make a simple pop-up. Here is how you get the page to ask for some personal input
var name = prompt("What is your name?","Name here");
This will put up a prompt asking the person for there name. If this box were to pop up it would have the words name here already in the box. You could leave the space between the second set of qoutes blank if you don't want a default value already in the box.
Now how to use the value stored in name in your pop-up
Here is an addition to the alert statement
I have placed the variable name within the alert box. The text of the alert is within qoutes, the variable is outside of the qoutes and must have the plus sign before it.
You could continue the text after the variable as
alert("Hello, "+name+" Welcome to my page");
You'll notice I made spaces within the qoutes otherwise you'll get Hello,BobWelcome to my page. Instead of Hello, Bob Welcom to my page
So now Here is the complete script for a prompt followed by a pop-up
If you want to control when a new line starts add this to your alertLesson 1
alert("Hello, "+name+"\nWelcome to my page");
I put the \n after the second qoute so that right after the Hello Bob A new line would start. Welcome to my page instead of having the browser choose when to make the break wich can make your alert look funny
Try you hand at editing a short welcome script in. A sample script is below the editing window. Copy it to the window if you wish, and try changing the way the question and alert is worded. Try changing the place of the variable name and anything else you wish to try. If you like what you have made copy it and enter it into your page editor.
Once you've got that down go on to
On to even more
Sign my GuestBook
View my GuestBook
Read my DreamBook
Sign my DreamBook
of the Week
An interactive weekly quiz. Some of wich I write
| MEMBER |
of the POD