![]() |
Part 2: Using the Prototype JavaScript Framework
As an extension to Wildhoney's introductory article on JavaScript, I have written this article to show how to achieve the same results from using Prototype. Please note that the code in this example could be compacted considerably using some of Prototypes advanced features. However, due to this being an introduction to Prototype, I have decided to go with a "more code, easier to read", approach.
Prototype, if you don't already know, is a popular JavaScript Framework. I have a slightly different style to Wildhoney, I'm going to go ahead and paste the complete source code with extensive comments to help you understand what's going on. javascript Code:
If you go ahead and run the code you'll see that we've achieved the exact same results that we got from Wildhoney's article. However, this time, we've achieved it using Prototype's excellent Framework. If you were to remove all the comments, you'll see the code is much easier to read and a lot more flexible. For more information on any of the function used in this example you can head over to the Prototype website: http://www.prototypejs.org |
Great tutorial, it just seems to be so darn easy.
|
It really is very easy and when you get comfortable with the structure of JavaScript and frameworks like Prototype you can produce code like the following (which is functionally the same as Karl's above).
javascript Code:
|
That is so easy!
|
you can also use dom:loaded
expl. Code:
document.observe("dom:loaded", function() { |
| All times are GMT. The time now is 10:03 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0