Some irrelevant information to fill up the page
PHP code is executed on the SERVER, it never reaches the client
(browser), who just sees what's done by print statements.
where it can be executed (or not.)
resources on the server, but it can respond immediately and locally to
respond to events
, such as:
Click, Change, MouseOver, Submit (of a form)
How does it differ from PHP?
The syntax is basically the same. All the funny symbols you learned: =,
==, !, &&, etc. are the same. if, function ...
Between <script> ... </script> tags. Wherever
you want to write something (usually variable). In the <head>
section where you are not writing, for instance, for declaring a
need to provide alternatives. This is done between
<noscript> .. </noscript> tags, where you put HTML
document.write("Hello from " + myname);
Hello from me
You can also
when the event happens. For instance:
onMouseOut="this.style.color='blue';"> try this </em>
What does this do? Well, try this
now. But avoid
clicking on this.
3 popup boxes
pop up a box. Each takes one argument, a string that will be displayed
in the box. They are:
- alert( message ) -- Gives some information,
warning, etc. User clicks OK to make it go away.
- confirm( question ) -- Asks a question, and returns
the value true or false depening on users response.
- prompt( whatfor ) -- presents a text box for some
input, such as a name that can then be written into the page.
Finding your errors!
If your script is "not working" it may be that there is an error. You
your user will not like to see them. (In the early days error messages
- Konqueror, Ephany: not available, use Firefox.
- IE: Click on the discreet yellow triangle icon in a lower corner
to discover your errors
You might want to clear the console initially, and reload the page you
are debugging -- There are usually a lot of errors from "professional"
pages! The Console tries to show you exactly where an error is
detected. Remember, the actual mistake may be several lines before.
and reasonable values. We will discuss this at length in the next