Article CATEGORIES

RSS Feeds

Tutorials

Articles

Blog

Friends and Affiliates

Website Statistics

Total tutorials : 6774
Total views : 1391561
Total votes : 11702

Category with most tutorials :
Photoshop (4212 Tutorials)
Category with most views :
Photoshop (699871 Views)
Category with most votes :
Photoshop (6418 Votes)
Related articles
No articles related to this article found in our database.

Writing Javascript for humans beings with Prototype - Part 1


Introduction

Javascript, as most of us knows is a scripting language based on the concept of prototype-based programming. The language is best known for its use in websites. If we go back 5 years, Javascript was something like Microsoft's authority, as Internet Explorer was the authority browser. They distorted the Javascript in any shape they wanted, and don't even bothered to have a documentation on their MSDN.

As new browsers borning, they are following standards and its becoming more hard to write multi browser compatible javascript. So Sam Stephenson created the Prototype JavaScript framework in February of 2005, this framework made the life of many developers even easier. Now a days, a lot of web applications are using Prototype. Some famous are Digg, FeedBurner, Amazon, Alexa and many others. So I think its time to get rid of non-human javascript and enter the new world of Javascript, which revolved around Prototype.

I will write about 5-6 more part of this articles that will include advance usage of Prototype. In this article, I have discussed basics of Prototype.

Before you read this article, I am assuming that you are pretty much fimiliar with Javascript and you are here to switch to a painless javascript. The latest version of Prototype can be downloaded from the prototype site. Simply download prototype.js and link it to your pages with a <script> tag:
<script type="text/javascript" src="PATH/TO/prototype.js"></script>

Lets Get Started

One nice thing about using Prototype is that it provides very simple functions for common tasks. The best example is "$" function. This function takes element ID(s) and return a references to them. For example,

$('header') // will return reference to the element with the ID 'header'

$('header', 'navigation', 'footer') // will return an array of element references


Another powerful function of Prototype is "$$". With this function, you can select elements using CSS selectors. Here are few examples

$$('div') // will return all DIVs in the document. Same as document.getElementsByTagName('div')

$$('li.nav') // will return all LI elements with class 'nav'

$$('#contents a[rel]') // will return all links inside the element of ID "contents" with a rel attribute

$$('a[href="#"]') // will return all links with a href attribute of value "#"


While having a big form, "myForm.myInputElement.value" really sucks. Prototype have got a very handy function for it. "$F" takes an ID of any form element and return its value.

<input type="text" name="authorWebsite" value="www.google.com" />

$F('authorWebsite') // will return www.google.com


This is not end, Prototype have more handy functions. "document.getElementsByClassName" is another example. As we can conclude from its name that this function returns the list of element with the class name you provide.

document.getElementsByClassName('nav') // will return all elements with class 'nav'

document.getElementsByClassName('nav', $('sidelinks')) // will return all elements with class 'nav' and inside the element with ID 'sidelinks'


In this article, I discussed the very basics of Prototype. But this was just the first part. In next part of this article (which is supposed to be published on next weekend), I will discuss the "String", "Number" and "Array" methods that Prototype provides. So stay tuned and keep checking the website.

See Also

Going to start your new website or blog? Try this web hosting search before making any decision. You can find some reliable and cheap web hosting on that site. If you're current hosting needs are exceeding, you can also find dedicated server on that site at a very reasonable price.


Bookmark Article

Writing Javascript for humans beings with Prototype - Part 1 Writing Javascript for humans beings with Prototype - Part 1 Writing Javascript for humans beings with Prototype - Part 1 Writing Javascript for humans beings with Prototype - Part 1 Writing Javascript for humans beings with Prototype - Part 1 Writing Javascript for humans beings with Prototype - Part 1 Writing Javascript for humans beings with Prototype - Part 1 Writing Javascript for humans beings with Prototype - Part 1 Writing Javascript for humans beings with Prototype - Part 1


Share Article

Liked this tutorials? Want to put a link on your website, please use following code


About Author

Abdullah Ibrahim AKA designcode is 20 year old web developer having skills over PHP, MySQL, XML, SOAP, AJAX, Javascript, Photoshop, Flash, XHTML and CSS. He loves to create rich web 2.0 applications.

Apart from his day time Job as a Software Developer, he also do web designing and development as a freelancer web designer and developer.

In his free time, that he rarely have, he like to read books, listen music and hangout with friends.

Latest Resources

Create a Retro Rainbow Waterfall Using 3DS Max Create a Retro Rainbow Waterfall Using 3DS Max
Create an outstanding 3D Retro Waterfall Artwork in 3DS Max using Particle Flow and some simple boxes!
Category: 3ds-models 3DS Models
Free WordPress Theme to Download Free WordPress Theme to Download
10 Premium wordpress Themes Download Free Psd Files.
Category: wordpress-themes WordPress Themes
Free Fireworks Brushes Free Fireworks Brushes
I have created a free Firework brush package, that you can download here. You can use the brushes for personal and ...
Category: photoshop-brushes Photoshop Brushes
10 Free Clothing Textures 10 Free Clothing Textures
I created 10 Free Clothing Textures that you can download here.
Category: photoshop-plugins Photoshop Plugins
Photoshop Brushes Huge Pack Photoshop Brushes Huge Pack
Exclusive Shiny Photoshop Brushes Huge Pack
Category: photoshop-brushes Photoshop Brushes

Most Viewed

Exterior Scenes in 3d Max Exterior Scenes in 3d Max
Developing an understanding of the subject and discovering how to best portray its character is a crucial step in composing your ...
Category: 3d-studio-max 3D Studio Max
Photoshop Fashion Model Photoshop Fashion Model
learn how to create cool looking model from simple image
Category: photoshop Photoshop
Romantic blue background Romantic blue background
Make a romantic blue background with adjustment color
Category: photoshop Photoshop
 Simple Ashing Effect Simple Ashing Effect
Create a simple “Ashing” effect using 3DSMax’s Particle Flow. This effect used in many movies such as Blade or IronMan.
Category: 3d-studio-max 3D Studio Max
Create Professional looking two pages Magazine Cover Create Professional looking two pages Magazine Cover
In today tutorial I`m gonna show you how you can create a professional looking Magazine cover, by using a random images. ...
Category: photoshop Photoshop

Top Rated

Create an illustration of a fountain pen Create an illustration of a fountain pen
In this first tutorial you’ll learn to create an illustration of a fountain pen. It is more of an advanced tutorial ...
Category: illustratorIllustrator
How to create a mobile phone friendly website design How to create a mobile phone friendly website design
I have noticed that web masters mainly prefer to use simple HTML codes to make a website to be displayed more ...
Category: photoshopPhotoshop
Make the Sun Shine in Photoshop Make the Sun Shine in Photoshop
In this Photoshop tutorial we´ll make the sun shine with bright and colorful atmosphere. Are you the kind of photographer who ...
Category: photoshopPhotoshop
How to Create a Business Designed Web Layout How to Create a Business Designed Web Layout
Today´s photoshop tutorial we will create a really nice looking business web layout. It is a were detailed tutorial that will ...
Category: photoshopPhotoshop
Exterior Scenes in 3d Max Exterior Scenes in 3d Max
Developing an understanding of the subject and discovering how to best portray its character is a crucial step in composing your ...
Category: 3d-studio-max3D Studio Max
Home | About Us | Advertise | Link to Us | Contact Us Privacy Policy | Disclaimer | Terms of Uses
Copyright 2006-2009. Please do not use website contents without our permissions.