Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

javascript Öеļ̳з½·¨

1.¿ÉÒÔͨ¹ýprototypeÊôÐÔ£¬ÊµÏּ̳з½·¨µÄ·½Ê½£¬ÕâÖÖ·½Ê½¾ÍÊÇjavaÓïÑÔÖм̳еı任ÐÎʽ¡£
 // Create the constructor for a Person object
function Person( name ) {
    this.name = name;
}
// Add a new method to the Person object
Person.prototype.getName = function() {
    return this.name;
};
Person.prototype.setName = function(name) {
    this.name = name;
};
// Create a new User object constructor
function User( name, password ) {
    // Notice that this does not support graceful overloading/inheritance
    // e.g. being able to call the super class constructor
    this.name = name;
    this.password = password;
};
// The User object inherits all of the Person object's methods
User.prototype = new Person();
2.ͨ¹ý×Ô¼ºÐ´¼Ì³Ðº¯Êý£¬ÊµÏּ̳У¬ÏÂÃæÕâ¶Î´úÂëÒ²ºÜºÃ£¬ÖµµÃÒ»¿´
// A simple helper that allows you to bind new functions to the
// prototype of an object
Function.prototype.method = function(name, func) {
    this.prototype[name] = func;
    return this;
};
// A (rather complex) function that allows you to gracefully inherit
// functions from other objects and be able to still call the  'parent'
// object's function
Function.method('inherits', function(parent) {
    // Keep track of how many parent-levels deep we are
    var depth = 0;
    // Inherit the parent's methods
    var proto = this.prototype = new parent();
    // Create a new 'priveledged' function called 'uber', that when called
    // executes any function that has been written over in the inheritance
    this.method('uber', function uber(name) {
        var func; // The function to be execute
        var ret; // The return value of the function
 &n


Ïà¹ØÎĵµ£º

JavaScript FAQ£¨¶þÊ®Èý£©

¶þÊ®¡¢Bookmarklet
1¡¢Ê²Ã´ÊÇBookmarklet£¿£¨What's a Bookmarklet?£©
Q£ºÊ²Ã´ÊÇBookmarklet£¿
A£ºBookmarkletÊÇÕû¸ö¶¼±»°üº¬ÔÚ³¬Á´½ÓURLÖеÄһС¶ÎJavaScript³ÌÐò¡££¨JavaScript URL¾ÍÊÇÕâ¸öÑù×Ó£º<a href="javascript:the code goes here">¡££©¶àÊýä¯ÀÀÆ÷ÔÊÐíÓû§Ìí¼ÓÕâЩJavaScript URLÊéÇ©£¬¾ÍÏñÌí¼ÓÆäËû³¬Á´½ ......

JavaScript prototype ÊôÐÔ

¶¨ÒåÓëÓ÷¨
The prototype property allows you to add properties and methods to an
object.
prototypeÊôÐÔÔÊÐíÄãÏòÒ»¸ö¶ÔÏóÌí¼ÓÊôÐԺͷ½·¨
Syntax
Óï·¨
object.prototype.name=value
Example 1
ʵÀý
In this example we will show how to use the prototype property to add a
property to an object:
ÔÚÏÂ ......

JS(javascript)²Ù×÷Êý¾Ý¿â

//°ÑÊý¾ÝдÈëÊý¾Ý¿â
function
res(){
    //»ñÈ¡ÊäÈëÖµ(mynameºÍmymailÊÇÁ½¸öÎı¾¿òµÄid)
    var
uname = document.getElementById("myname"
).value;
    var
umail = document.getElementById("mymail"
).value;
......

JavaScriptʵ¼ÊÓ¦Ó㺶ԲãµÄ¿ØÖÆ

²ãµÄ¿ª·¢ÔÚʵ¼ÊÓ¦ÓÃÖбȽÏÖØÒª£¬±ÈÈçÆ¯¸¡¹ã¸æµÈµÈ£¬ÎÒÕâÀï¼òµ¥Ì½ÌÖһϡ£
1.  ¿ØÖƲãµÄÏÔʾ»òÒþ²Ø
Á½ÖÖ°ì·¨£¬Æäʵ¶¼ÊÇ¿ØÖÆÑùʽµÄ¡£
°ì·¨Ò»£º¿ØÖÆ display ÊôÐÔ
<script language="javascript">
function show(status)
{
          document.getElemen ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ