The word "Prototype" here is not a prototype ("Prototype") in JavaScript programming, but a JavaScript library written by Sam Stephenson. This wonderfully conceived and standard class library helps programmers easily build rich-client pages with highly interactive "web2.0" features.
• Many people first contact with prototype, starting with their "$" series functions, which resemble desktop application shortcuts, are the most frequently used set of functions in the prototype framework. In addition, prototype's support for Ajax is an interesting place for developers. Of course, the functionality of prototype is not limited to this, it extends the JavaScript built-in objects a lot, but also defines a lot of new objects.
Introduction to the prototype framework:
prototype is the most widely used AJAX development framework, characterized by its functional utility and small size, is ideal for use in small and medium Web applications. Developing AJAX applications involves writing a large number of client JavaScript scripts, and the prototype framework can greatly simplify the writing of JavaScript code. More rarely, prototype has the excellent features compatible with each browser, which eliminates the need to consider browser compatibility issues.
prototype has a number of useful extensions to JavaScript's built-in objects, such as String objects, Array objects, and so on, as well as a number of custom objects added to the framework, including support for Ajax development, which are implemented in custom objects. Prototype can help developers achieve the following goals:
• (1) A variety of processing of strings
• (2) Access to collection objects using enumerations
• (3) Common DOM operations in a simpler way
• (4) Using CSS selectors to locate page elements
• (5) Initiate AJAX-style HTTP requests and process responses
• (6) Listening for DOM events and handling events
• "Prototype" Framework features-use the utility function
The implementation of the "Prototype" framework contains only one JavaScript, and the 1.6 version of "Prototype.js" has a file size of 127K bytes and about 4220 rows. The syntax applied to the page is similar to the following:
<script type= "Text/javascript" src= "Inc" JS "Prototype.js" ></script>
• The convenience of the framework can then be enjoyed in subsequent scripts.
• There are many predefined objects and utility functions in the framework that allow programmers to free themselves from repetitive typing.
• (1) Use the "$ ()" function.
• (2) Use the "$F ()" function. This function is another big welcome shortcut key that can be used to return the values of any form input control, such as a multiline text box and a drop-down list box. This method can also be used as an argument with an element ID or an element itself.
• (3) Use the "$A ()" function. This function converts a single parameter that it receives to an array object.
• (4) Use the "$H ()" function. This function converts some objects into a hash object that is similar to an enumerable and federated array.
• (5) Use the "$R ()" function. This function is the abbreviation for "New Objectrange (Lowbound,upperbound,excludebounds)", which is used to establish a scope object.
• (6) Use the "Try.these ()" function. The "Try.these ()" method is used to invoke a different method until one of them succeeds. This function takes a series of methods as parameters and executes them sequentially one by one, until one of them executes successfully. Returns the return value of the method that was successfully executed. The Try.these () function can be used to handle compatibility issues.