JavaScript Part Deux
Last week I talked about some of the simple things that JavaScript could be used for when building a website. This week I will go a little more depth with some of the "how" and also talk about why we need to be including JavaScript in our website and web development plans.
JavaScript is the first step in web designing that brings our static HTML webpages to life. It is used to add user interactivity to or otherwise unidirectional HTML page. JavaScript allows us to have a prompt box appear that welcomes visitors to the site as they visit, or thanks them as they leave. These two are very simplistic examples, but I hope it shows the overall point that I want to make, which is that JavaScript is the reason why websites and the Internet as a whole was able to become an avenue for two-way communication, rather than being the equivalent of books, magazines and newspaper digitized to a computer screen.
This is the exact reason why we absolutely must include JavaScript into our websites and web development plans. If we don't, then our website will be as useful to people today as a site that they are viewing that was made back in the 90's!
So let's go a little more into the "how" now, shall we? By "how" I don't mean actually showing how to write the code (the resources in my last post can do a much better job than I can). What I want to show is how JavaScript can be used to accomplish some basic things, and when multiple of these things are combined, a more complicated element can be achieved. Let's start with this simple script:
This is the exact reason why we absolutely must include JavaScript into our websites and web development plans. If we don't, then our website will be as useful to people today as a site that they are viewing that was made back in the 90's!
So let's go a little more into the "how" now, shall we? By "how" I don't mean actually showing how to write the code (the resources in my last post can do a much better job than I can). What I want to show is how JavaScript can be used to accomplish some basic things, and when multiple of these things are combined, a more complicated element can be achieved. Let's start with this simple script:
Now this piece of script might look complicated, but in actuality its no more difficult to understand than having a few If-Then statements from Algebra class. Now you might be saying, "But Algebra class was difficult!", so let me just tell you I understand, because Algebra class was no cake walk for me either. However, when we look at what this is telling us, or more importantly the web browser, all it is doing is setting a few variable conditions that, when met will tell the browser to deliver a specific result, or not to deliver a result.
An example of how the above can be used is if you have a site where you want runners to log the distance that they run per day. Let's just say that you are tracking them in meters. Now, when the runner enters in their data for the day, and they ran over 100 meters, this script is setup to recognize that as being "too far", and you can have a specific prompt or action to come up that maybe congratulates the runner for an over achievement.
The same concept would apply to someone who logs a run for less then the distance you are requesting that they run. Hopefully it can be seen how useful this could be, even on a level this basic.
That is the beautiful thing about JavaScript; It allows us to truly begin implementing client-side interactivity into our websites with a variety of responses for different scenarios. Hope this week helped a little more with understanding JavaScript and what it can be used for and why. If you have any experience with JavaScript, or you are even just interested in starting it, please leave a comment below telling your thoughts and/or experiences with it. I would really like to here from you!
No comments:
Post a Comment