Page 15
Function Exercise
Here's a snazzy way to give people a chance to go to another URL without having to drag their mouses all the way to the Location window: Where are you heading?
The neat thing about this script is that people can type either http://some.address.com or just some.address.com. If they do the latter, JavaScript will figure it out and append http:// to the front of what they type. Give it a try. Type www.hits.org and you'll see that the script appends the http:// on the front.
Your assignment, of course, is to do this. You'll need one tip though. To check the first few letters of the typed URL, you need to do this:
var the_first_seven = the_url_they_typed.substring(0,7);
After you do this, the_first_seven will hold the first seven characters of the string typed into the prompt.
Try doing this exercise. If you give up, View Source for the solution. Try it first, though! Then go on to the final exercise for this lesson.
next page»
|