Intermediate HTMLLesson 3: How to add programming to your pages without being a programmerIncorporating some Javascript into a page
Your textbook has an excellent section on Javascript, starting on page 313, which explains the anatomy of Javascript and tells you how to code some scripts from scratch. If you want to start actually understanding and writing Javascript, I suggest you read Chapters 18 and 19. The goal of this lesson is simply to get you to the point where you know how to take advantage of the work that hundreds of programmers have already done and have obligingly offered to share. The cut-and-paste approachLet's say you want to put a "Back >" button on your page. You know, those pages that say "| <Back | Page 2 |". Go to The JavaScript Source. In the Search box, type "back button". Well, look at that! The very first result is "Still wondering how to create a back button from a ... "! Click on that link. The first thing you see after the description of the script is a demo of how it works. You can run it to make sure it does what you want it to do. The next thing you see is a scrollable inline frame. (If you don't remember what an inline frame is, please go back and study Lesson 2.) Within that frame are step by step instructions, followed by code to cut and paste into your page. In this case, there's only one step because this is a simple script. More complicated scripts require two steps, as we'll see. The parts enclosed in <!-- ... --> are comments. Your visitor doesn't see them when she views your page. The last part, with the link to the site, is the "fee" you pay for using their script: you put a link to the site somewhere on your page. (It doesn't necessarily have to be right where the script is embedded. The bottom of your page will do.) Try cutting and pasting this script into one of your pages. Notice, they give you two flavors: the text link "Back" and the button. You can choose one or the other. Did it work? Yeay! Questions, comments or problems? Post to the forum. |