Prototype framework details, prototype framework
The "Prototype" mentioned here is not a prototype in JavaScript programming, but a JavaScript class library written by "Sam Stevenson. This fantastic idea and compatible with standard class libraries can help programmers easily build rich client pages with highly interactive "web2.0" features.
• Many people first came into contact with Prototype functions starting with their "$" series. These shortcuts are similar to those of desktop applications and are the most frequently used functions in the Prototype framework. In addition, Prototype's support for Ajax is also a matter of great interest to developers. Of course, Prototype is not limited to this function. It expands a lot of JavaScript built-in objects and defines many new objects.
Introduction to the prototype framework:
• Prototype is currently the most widely used Ajax development framework. It features functionality and a small size and is very suitable for small and medium Web applications. A large number of client JavaScript scripts are required to develop Ajax applications, and the Prototype framework can greatly simplify the JavaScript code writing. Even more rare, Prototype is compatible with the excellent features of various browsers. Using this framework, you do not have to consider browser compatibility issues.
• Prototype provides many useful extensions for built-in JavaScript objects (such as "String" objects and "Array" objects). In addition, many custom objects are added to the framework, support for Ajax development is implemented in custom objects. Prototype helps developers achieve the following goals:
• (1) various processing of strings
• (2) use enumeration to access collection objects
• (3) perform common DOM operations in a simpler way
• (4) use the CSS selector to locate page elements
• (5) initiate an HTTP request in Ajax mode and process the response
• (6) Listen to DOM events and process them
• "Prototype" framework function description-use of practical functions
The implementation of the "Prototype" framework only contains one JavaScript file. The size of the "Prototype. js" file in version 1.6 is kb, about 4220 rows. The syntax applied on the page is similar:
•<script type=”text/javascript” src=”inc"js"Prototype.js” ></script>
• Then you can enjoy the convenience brought by this framework in subsequent scripts.
• The framework has many predefined objects and utility functions that can free programmers from repeated typing.
• (1) use the "$ ()" function.
• (2) use the "$ F ()" function. This function is another popular shortcut that can be used to return the values of any form input controls, such as multi-line text boxes and drop-down lists. This method can also use the element id or element itself as a parameter.
• (3) use the "$ A ()" function. This function can convert a single parameter it receives into an Array object.
• (4) use the "$ H ()" function. This function converts some objects into an enumerated Hash object similar to the Union array.
• (5) use the "$ R ()" function. This function is short for "new ObjectRange (lowBound, upperBound, excludeBounds)" and is used to create a range object.
• (6) use the "Try. these ()" function. The "Try. these ()" method is used to call different methods until one of them is successful. This function takes a series of methods as parameters and executes these methods one by one in order until one of them is successfully executed. Returns the return value of the method that is successfully executed. The "Try. these ()" function can be used to handle compatibility issues.