Page 26 - LoudOffice_Guide-to-HTML_Part-II_Advanced.PDF
P. 26
IV. Working with JavaScript in HTML
Now that the boring stuff is over, let’s look at what we can do with JavaScript in our HTML
documents. We’re going to cover a number of common applications with JavaScript. This
will represent simply 1/100 of you can do with JavaScript in your HTML documents. If you
are interested in seeing more, visit the links section of the LoudOffice.com class website.
Alerts, Prompts, and Confirms
Alerts
It is possible to send a message back to the user by creating an instance of an alert box:
< h t m l >
< h e a d >
< t i t l e > W e l c o m e < / t i t l e >
< / h e a d >
< b o d y o n L o a d = ” a l e r t ( ‘ W e l c o m e t o m y W e b s i t e ! ’ ) ; “ >
H e l l o
< / b o d y >
< / h t m l >
Naturally, these alerts can also appear within a function:
< s c r i p t l a n g u a g e = ” J a v a S c r i p t ” >
< ! - - / / H i d e
f u n c t i o n S a y H e l l o ( ) {
a l e r t ( “ S a y H e l l o ” ) ;
}
/ / U n h i d e - - >
< / s c r i p t >
LoudOffice.com Guide to HTML – Part II Page 26