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

Javascript Ô­Ðͺͼ̳Ð(Prototypes and Inheritance)

Javascript Ô­Ðͺͼ̳Ð(Prototypes and Inheritance) ÊÕ²Ø
 Ç°ÃæÎÒÃÇ¿´µ½ÁËÈçºÎʹÓà constructor À´³õʼ»¯¶ÔÏó¡£Èç¹ûÕâÑù×ö£¬ÄÇôÿһ¸ö´´½¨µÄжÔÏ󶼻á¶ÔÄÇЩÏàͬµÄÊôÐÔ£¬·½·¨½¨Á¢Ò»¸ö¶ÀÁ¢µÄ¸±±¾¡£¶øʵ¼ÊÉÏÓиü¼ÓÓÐЧµÄ·½·¨À´Ö¸¶¨·½·¨£¬³£Á¿£¬ÒÔ¼°ÆäËûһЩ¿É±»ËùÓиÃÀàµÄ¶ÔÏó¹²ÏíµÄÊôÐÔ¡£
JavaScript ¶ÔÏó´ÓÒ»¸öÔ­ÐζÔÏó(prototype object) ¼Ì³ÐÊôÐÔ¡£ËùÓжÔÏó¶¼ÓÐÔ­ÐÍ£»Ô­Ð͵ÄËùÓÐÊôÐÔ¿´ÉÏÈ¥¾ÍÏñʹÓÃËü×÷ΪԭÐ͵ÄÄÇЩ¶ÔÏóµÄÊôÐÔÒ»Ñù¡£¼òµ¥µÄ˵¾ÍÊÇ£ºËùÓжÔÏ󶼴ÓËûµÄÔ­Ðͼ̳ÐÊôÐÔ¡£
(each object inherits properties from its prototype).
¶ÔÏóµÄ prototype ͨ¹ýËüµÄ constructor function À´¶¨Òå¡£JavaScript ÀïËùÓÐµÄ function ¶¼ÓÐÒ»¸ö prototype ÊôÐÔ¡£Õâ¸öÊôÐÔ¿ªÊ¼Êǿյģ¬½ÓÏÂÀ´Äã¸øËûÌí¼ÓµÄÈκÎÊôÐÔ¶¼»á±» constructor ´´½¨µÄ¶ÔÏóËùÓµÓС£
prototype ¶ÔÏóºÍ constructor Ïà¹ØÁª¡£ÕâÒâζ×Å prototype ¿ÉÒÔ×÷Ϊ·ÅÖ÷½·¨ÒÔ¼°ÆäËû³£Á¿µÄÀíÏ볡Ëù¡£Ô­ÐÍÖеÄÊôÐÔ²»»á±»¸´ÖƵ½Ð´´½¨µÄ¶ÔÏóÖÐÈ¥£¬ËûÃǵÄÊôÐÔ¿´ÉÏÈ¥¾ÍÏñ¶ÔÏóµÄÊôÐÔÒ»Ñù¡£ÕâÒâζ×Å£¬Ê¹ÓÃÔ­ÐÍÄܹ»´ó·ù¶ÈµÄ¼õÉÙ¶à¸öͬÀà¶ÔÏóÕ¼ÓõÄÄÚ´æ¡£
ÿһ¸ö class ¶¼Ö»ÓÐÒ»¸ö prototype object, ¸½´øÒ»Ì×ÊôÐÔ¡£µ«ÎÒÃÇÔÚÔËÐÐʱ¿ÉÄܻᴴ½¨¶à¸öÀàµÄʵÀý¡£ÄÇôÈç¹û·¢Éú¶ÔÔ­Ð͵ÄÊôÐԵĶÁд»á·¢ÉúʲôÇé¿ö£¿
µ±Äã¶ÁÒ»¸öÊôÐÔµÄʱºò£¬JavaScript Ê×Ïȳ¢ÊÔÈ¥²éÕÒ¶ÔÏó±¾ÉíÊÇ·ñÓÐÕâ¸öÊôÐÔ£¬Èç¹ûûÓУ¬½Ó×ÅÈ¥²éÕÒÔ­ÐÍÀïÃæÊÇ·ñÓС£ÓеĻ°¾Í·µ»Ø½á¹û¡£
¶øµ±ÄãдԭÐ͵ÄÊôÐÔµÄʱºò£¬ÒòΪ¶à¸ö¶ÔÏó¹²ÏíÔ­ÐÍ£¬ÏÔÈ»ÊDz»ÄÜÖ±½ÓÔÚÔ­ÐÍÉϽøÐÐд²Ù×÷µÄ¡£Õâ¸öʱºòʵ¼ÊÉÏ JavaScript »áÔÚ¶ÔÏóÉÏ´´½¨Ò»¸öͬÃûµÄÊôÐÔ£¬È»ºó°Ñֵдµ½ÀïÃæ¡£µ±ÄãÏ´ζÁÕâ¸öÊôÐÔµÄʱºò£¬JavaScript Ò»ÏÂ×Ó¾ÍÔÚ¶ÔÏóµÄÊôÐÔÀï²éÕÒµ½ÁË£¬ÄÇô¾Í²»ÐèҪȥԭÐÍÀï²éÕÒÁË¡£Õâ¸öʱºò£¬ÎÒÃÇ˵“¶ÔÏóµÄÊôÐÔÑڸǻòÒþ²ØÁËÔ­Ð͵ÄÊôÐÔ”¡£(shadows or hides) ¡£
´ÓÉÏÃæÌÖÂÛ¿´³ö£¬ÆäʵÎÒÃÇÔÚÉè¼ÆÀàµÄʱºò£¬Ö»ÒªÕÆÎÕÒ»¸öÔ­Ôò£ºÔÚÔ­ÐÍÀï½ö¶¨ÒåһЩ·½·¨£¨·½·¨Ò»°ãÊDz»»á±äµÄ£©£¬³£Êý£¬³£Á¿µÈ¡£×öµ½ÕâÒ»µã¾Í²»ÈÝÒ×»ìÏýÁË¡£
Àý×Ó£º
// Define a constructor method for our class.
// Use it to initialize properties that will be different for
// each individual Circle object.
functionCircle(x, y, r)
{
    this.x = x;  // The X-coordinate of the center of the circle
 
this.y =


Ïà¹ØÎĵµ£º

javascript ÅжÏÎļþÀàÐÍ


function checkfiletype()
{
   var fileName = document.getElementById('<%=FilePath.ClientID%>').value;
   if (Trim(fileName)=="")
        {
            alert("ÇëÑ¡ÔñÒªÉÏ´«µÄÎļþ£¡");
     ......

css,javascriptµÄÔ¤¼ÓÔØ

ΪÁËÌá¸ßÍøÕ¾µÄ¼ÓÔØËٶȣ¬ÓÐÒ»¸öºÜÖØÒªµÄÊֶξÍÊÇÔÚÓû§ä¯ÀÀ¹ý³ÌÖеÄÉÏÓÎÍøÕ¾×öÒ»¸öÎļþµÄÔ¤¼ÓÔØ¡£Ô¤¼ÓÔØÎļþÒ»°ãÓÐÁ½ÖÖ³£Óõķ½Ê½£ºxhrºÍ¶¯Ì¬²åÈë½ÚµãµÄ·½Ê½¡£¶¯Ì¬²åÈë½ÚµãÊÇ×îΪ¼òµ¥Ò²×îΪ¹ã·ºµÄÒ»ÖÖÒì²½¼ÓÔØ·½Ê½(ÀýÈçyuiµÄGetÄ£¿é)£¬È»ºóʹÓö¯Ì¬²åÈë½Úµã·½·¨¼ÓÔصÄÎļþ¶¼»áÔÚ¼ÓÔغóÁ¢¼´Ö´ÐУ¬javascriptµÄÖ´ÐÐÒ»·½Ãæ»áÕ ......

javascript ÕýÔò


1 javascript ÕýÔò
¶ÔÏó´´½¨ ºÍÓ÷¨
ÉùÃ÷javascript ÕýÔò
±í´ïʽ
¸´ÖÆ´úÂë
´úÂëÈçÏÂ:

var reCat = new RegExp("cat");
ÄãÒ²¿ÉÒÔ
var reCat = /cat/; //Perl ·ç¸ñ £¨ÍƼö£©

2 ѧϰ×î³£ÓÃµÄ test exec match search replace split 6¸ö·½·¨
1£© test ¼ì²éÖ¸¶¨µÄ×Ö·û´®ÊÇ·ñ´æÔÚ
¸´ÖÆ´úÂë
......

ʹÓÃJavaScriptºÍAjax·¢³öÒì²½ÇëÇóÏê½â

´ò¿ªÇëÇó
¡¡¡¡ÓÐÁËÒªÁ¬½ÓµÄ URL ºó¾Í¿ÉÒÔÅäÖÃÇëÇóÁË¡£¿ÉÒÔÓà XMLHttpRequest ¶ÔÏóµÄ open() ·½·¨À´Íê³É¡£¸Ã·½·¨ÓÐÎå¸ö²ÎÊý:
request-type:·¢ËÍÇëÇóµÄÀàÐÍ¡£µäÐ͵ÄÖµÊÇ GET »ò POST£¬µ«Ò²¿ÉÒÔ·¢ËÍ HEAD ÇëÇó¡£
url:ÒªÁ¬½ÓµÄ URL¡£
asynch:Èç¹ûÏ£ÍûʹÓÃÒì²½Á¬½ÓÔòΪ true£¬·ñÔòΪ false¡£¸Ã²ÎÊýÊÇ¿ÉÑ¡µÄ£¬Ä¬ÈÏΪ true¡£
......

javascriptʼþÇý¶¯¿ò¼Ü ÊÕ²Ø

  javascriptʼþÇý¶¯¿ò¼Ü ÊÕ²Ø
Ò»¸ö¼òµ¥µÄʼþÇý¶¯¿ò¼ÜµÄÑÝʾ£º
/*ControlDemo.js*/
//ʼþÇý¶¯¿ò¼Ü£¨ÑÝʾ£©
function ControlDemo(page)
{
 //³õʼ»¯Page
 if (page == null)
 {
  page = self;
 }
 if (page != self)
 {
  //Do sth. here...
 }
&nb ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ