Intermediate HTMLLesson 3: How to add programming to your pages without being a programmerThat's nice. What else have you got?
You now know how to utilize online Javascript source libraries. There are more of them in the list of suggested links associated with this course, but I've usually found what I wanted in The JavaScript Source. Just to reinforce the lesson, let's cut and paste a more complex script. This time we're going to insert a game. Go to The JavaScript Source again. In the links at the top of the page, just below the ads, click on "Games". See the second script listed below the "sponsored listings"? The one that says "Arrange"? Ok, click on that link. Now check out the game to make sure it's something you want in your page. I'll wait. Finished playing?Not yet? If you copy it successfully, you can have it in your own page to play any time. Okay? Okay. Let's look at what's in the inline frame. The instructions at the top have three steps. To incorporate this game into a page of your own, you have to complete all three steps. So. The instructions for the first step say "Paste this code into the HEAD of your HTML document." Obligingly, they've placed <HEAD> and </HEAD> tags to show you where the code to copy begins and ends. Ok. Highlight the code between the tags and paste it into the HEAD section of your page, preferably at the end, after the meta tags. For this particular script, what's going into the HEAD is just some stylesheet declarations, but most of the time, it's some code. Doesn't matter. You just have to make sure you copy it all and put it into the right spot in your page. The next step is to copy the fragment that goes within the BODY tag. If you have other stuff in your BODY tag, like a background color for the page, for instance, you can leave that where it is. The "onLoad" code is just one part of the BODY tag. You can have other stuff in there, as long as you separate each part with a space. This "onLoad" code gets executed when the page first loads into someone's browser. Well, duh. Last step is to paste the rest of the code into the body of your page. See how much of it there is? Guess what! You don't have to know what the heck any of it means in order to use it. Just make sure you get all of it. And don't forget to do the right thing and paste the link to the site somewhere into your page. You'll recognize some of the code you're copying as HTML. Feel free to modify that part -- the style specs in the head section too, if you want. Just don't change the parts between the <script> </script> tags, or the programming won't work. Now test it. Didn't work, did it? Hard stuff usually doesn't the first time around. See if you can figure out what you did wrong (i.e., debug it). If you get stuck, call for help on the forum. |