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

javascriptµÄOO¼Ì³Ð


ÔÚprototype¿ò¼ÜÖеÄÀà¼Ì³ÐʵÏÖ»úÖÆ
//ΪObjectÀàÌí¼Ó¾²Ì¬·½·¨£ºextend
Object.extend = function(destination, source) {
  for(property in source) {
     destination[property] = source[property];
  }
  return destination;
}
//ͨ¹ýObjectÀàΪÿ¸ö¶ÔÏóÌí¼Ó·½·¨extend
Object.prototype.extend = function(object) {
  return Object.extend.apply(this, [this, object]);
}
Object.extend·½·¨ºÜÈÝÒ×Àí½â£¬ËüÊÇObjectÀàµÄÒ»¸ö¾²Ì¬·½·¨£¬ÓÃÓÚ½«²ÎÊýÖÐsourceµÄËùÓÐÊôÐÔ¶¼¸³Öµµ½destination¶ÔÏóÖУ¬²¢·µ»ØdestinationµÄÒýÓá£ÏÂÃæ½âÊÍÒ»ÏÂObject.prototype.extendµÄʵÏÖ£¬ÒòΪObjectÊÇËùÓжÔÏóµÄ»ùÀ࣬ËùÒÔÕâÀïÊÇΪËùÓеĶÔÏó¶¼Ìí¼ÓÒ»¸öextend·½·¨£¬º¯ÊýÌåÖеÄÓï¾äÈçÏ£º
Object.extend.apply(this,[this,object]);
ÕâÒ»¾äÊǽ«ObjectÀàµÄ¾²Ì¬·½·¨×÷Ϊ¶ÔÏóµÄ·½·¨ÔËÐУ¬µÚÒ»¸ö²ÎÊýthisÊÇÖ¸Ïò¶ÔÏóʵÀý×ÔÉí£»µÚ¶þ¸ö²ÎÊýÊÇÒ»¸öÊý×飬°üÀ¨Á½¸öÔªËØ£º¶ÔÏó±¾ÉíºÍ´«½øÀ´µÄ¶ÔÏó²ÎÊýobject¡£º¯Êý¹¦ÄÜÊǽ«²ÎÊý¶ÔÏóobjectµÄËùÓÐÊôÐԺͷ½·¨¸³Öµ¸øµ÷Óø÷½·¨µÄ¶ÔÏó×ÔÉí£¬²¢·µ»Ø×ÔÉíµÄÒýÓá£ÓÐÁËÕâ¸ö·½·¨£¬ÏÂÃæ¿´Àà¼Ì³ÐµÄʵÏÖ£º
<script language="JavaScript" type="text/javascript">
<!--
//¶¨Òåextend·½·¨
Object.extend = function(destination, source) {
  for (property in source) {
     destination[property] = source[property];
  }
  return destination;
}
Object.prototype.extend = function(object) {
  return Object.extend.apply(this, [this, object]);
}
//¶¨Òåclass1
function class1(){
      //¹¹Ô캯Êý
}
//¶¨ÒåÀàclass1µÄ³ÉÔ±
class1.prototype={
      method:function(){
           alert("class1");
      },
      method2:function(){
           alert("method2");
      }
}
//¶¨Òåclass2
function class2(){
      //¹¹Ô캯Êý
}
//ÈÃclass2¼Ì³ÐÓÚclass1²¢¶¨ÒåгÉÔ±
class2.prototype=(new c


Ïà¹ØÎĵµ£º

Javascript¼Ì³ÐÖ®¶ÔÏóð³ä·¨

ÀýÈ磺ÓÐÈý¸öÀàclassX,classY,classZ
classZ·Ö±ð¼Ì³ÐclassXºÍclassY
ÓÚÊǾÍÓÐÏÂÃæµÄд·¨£º
function ClassZ(){
this.newMethod=classX;
this.newMethod();
delete this.newMethod;
this.newMethod=classY;
this.newMethod();
delete this.newMethod;
}
ÕâÖÖд·¨´æÔÚÒ»¸ö±×¶Ë.¡£Èç¹ûclassXºÍclassYÓоßÓÐͬÃûµÄÊô ......

ÓÃJavaScriptʵÏÖä¯ÀÀÆ÷״̬À¸·ÉÈëÎÄ×Ö

 //״̬À¸·ÉÈëÎÄ×Ö
function statusMessageObject(p,d) {  <!--????????????-->
  this.msg = MESSAGE
  this.out = " "
  this.pos = POSITION
  this.delay = DELAY
  this.i     = 0
  this.reset = clearMessage
}
function clearMessage( ......

JavaScript TextBoxÊäÈëÊý×Ö¿ØÖÆ

var OnPasteCheckIntNum = function()
{
    if(window.clipboardData)
    {
        if(isNaN(window.clipboardData.getData('text')))
        {
          ......

MD5 javascript

 /*****************************************************************************
* md5.js
*
* A JavaScript implementation of the RSA Data Security, Inc. MD5
* Message-Digest Algorithm.
*
* Copyright (C) Paul Johnston 1999. Distributed under the LGPL.
************************************** ......

Ïê½âFirefox 3.5µÄÐÂJavaScriptÒýÇæ

 ±¾ÎÄ×÷ÕßΪDavid
Mandelin£¬©¤©¤Mozilla JavaScriptÍŶӹ¤×÷ÈËÔ±¡£
Firefox 3.5ÓµÓÐÒ»¸öȫеÄJavaScriptÒýÇ棬½Ð×öTraceMonkey£¬ÔÚ¸ÃÒýÇæÉÏÅÜJSÓ¦ÓÃÒª±ÈFirefox
3¿ìµ½3-4±¶£¬´Ó¶øΪÏÖÓеÄÍøÂçÓ¦ÓüÓËÙ¡£ÕâƪÎÄÕ´óÖµÄÃèÊöÒ»ÏÂÔÚTraceMonkeyÖаüÀ¨µÄÖØÒª²¿¼þ£¬ÒÔ¼°ËûÃÇÊÇÈçºÎ¼ÓËÙJavaScriptµÄ¡£Í¬Ñù£¬ÔÚÁ˽âÕâÐ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ