These were examples of Alert Functions.
You opened this page and oh my goodness, all those pop-up boxes! You thought they would never, ever end, didn't you! Then you finally get to this page and low and behold, 2 more boxes! So you're asking yourself, "Now what the heck was that?". Simple really, the first set were windows alert functions that require you to click before you can enter a page. The second set was a function being called from another function. The first functions were in the form of the window alert or pop-up box. The pop-up box actually called the 2 other boxes that were written into the function and put them into one new function. Now for some Conditional Statements.There are 2 types of conditional statements, if/else and switch statements. If/Else is used mostly for simple comparison of the values. If something is true then yes, if false then no. Almost a too simple comparison but you get the picture. The switch statement allows you to take a single variable value and execute a different line of code based on the value of the variable. If you wish to check for a different number of values, this can be an easier method then the use of a set of nested if/else statements. For this module we will only be looking at if/else statement As an example of an if/else statement, lets say that in order for me to go to a NASCAR race, I must have credentials. If I have credentials, I will go to the race, if I do not have credentials, I will not go to a race. Using the variable credentials and applying a "yes" to the if on the credential variable, it would simply return this statement in a document.write. I have credentials to Daytona, therefore The same would hold true by changing the if to a "no" thus calling the else statement into play. I do not have credentials for California, therefore Now lets say I have a lot of tracks I will receive credentials for. I can still use the if/else but narrow my document.write to only tracks that I will receive credentials from. If I will not receive credentials, I simply say I am not going without having to list the tracks. I will receive credentials from Atlanta, Nashville, Kentucky, Milwaukee, Chicago, Indianapolis, Michigan, Charlotte and Memphis so
Event Handlers In ActionThe following is an onCLick Window Alert. You will see when you click the button that 2 window alerts will come up. They will only be shown when you click the button, no other time. The following is a onMouseOver and onMouseOut event. By moving your mouse over the button, you will see a new saying in the Status Bar at the bottom of the page. Moving the mouse away removes the saying. Now For A Document ObjectThe following are going to show you different document properties you can use in JavaScript directly in your document. First I'll show you a "last modified". How this works is simply to have the JavaScript return that last modification date of the document. It is written as document.lastModified and placed into a document.write line. See How Often I Update My Site! Go on to the next page to see more examples of JavaScript at work! |