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

javascript prototype

 
ÏÂÃ涼ÊǸöÈËÀí½âÒÔ¼°²éÕÒµÄÍøÉϵÄ×ÊÁÏ,ÈçÓв»¶ÔµÄµØ·½ÇëÖ¸Õý
prototype
prototypeÔÚÕâÀïÊÇÔ­Ð͵ÄÒâ˼,²»ÊÇÖ¸ÄǸö¿ò¼Ü...
ÿ¸öº¯Êý¾ÍÊÇÒ»¸ö¶ÔÏó£¨Function£©£¬µ±º¯Êý±»½âÎöºó»áÌí¼ÓÒ»¸öprototypeµÄ¶ÔÏó,È»ºóprototype»áÌí¼ÓÒ»¸öconstructorµÄÊôÐÔ
ËüÖ¸ÏòÄǸöº¯ÊýµÄ
±ÈÈ綨ÒåÒ»¸öfunction test(){}
Ëü»á×Ô¶¯Ìí¼ÓÒ»¸öprototype ; ¼´test.prototype={}
 È»ºó prototype»á×Ô¶¯Ìí¼ÓÒ»¸ötest.prototype.constructor =test  ËüÊÇÖ¸Ï뺯Êý±¾ÉíµÄ
¿ÉÒÔ²âÊÔһϠÀý×ÓÈçÏÂ
function test(){
alert('a');
}
alert(test.prototype); //¿ÉÒÔ¿´³öÊÇobj
test.prototype.constructor(); //¿ÉÒÔ¿´³öÊÇÖ´ÐÐÁËtest

Ò»¸öÀà,ÈçºÎʵÀý»¯³ÉÒ»¸ö¶ÔÏóÁË,ÀàÀïÃæµÄprototypeÀïµÄÊôÐÔÓÖÊÇÔõô³ÉΪʵÀýÀïÃæµÄÊôÐÔµÄÁË
ÕâÀï²»µÃ²»ËµÒ»ÏÂnew µÄ¹ý³Ì
´ó¸Å¿ÉÒÔ·Ö³É3²½
Õâ¸öÀý×Ó¿ÉÕæºÃѽ  ¹þ¹þ
<1> var p={}; Ò²¾ÍÊÇ˵£¬³õʼ»¯Ò»¸ö¶ÔÏóp¡£
<2> p.__proto__=Person.prototype;
<3> Person.call(p);Ò²¾ÍÊÇ˵¹¹Ôìp£¬Ò²¿ÉÒÔ³Æ֮Ϊ³õʼ»¯p¡£
±ðÈ˸øµÄÒ»¸önewµÄ¹ý³Ì
/*
new²Ù×÷Ô­Àí£¨spiderMonkeyÒýÇæÏ£©
*/
var a = function(sA,sH){
var x = "x";
this.a = sA;
this.h = sH;
this.say = function(){alert(this.a+','+x)}
}
a.prototype.hi = function(){alert(this.h)}
var createInstance = function(source){
var p = {}
var args = Array.prototype.slice.call(arguments,1);
source.apply(p,args);
p.__proto__ = source.prototype;
return p;
}
var A = createInstance(a,"A","hi A");
A.say();
A.hi();
ÈçÒ»¸öÀà ,new Ö®ºóµÄ¶ÔÏóÈçÏÂ
function test(){
this.name="taozi";
}
test.prototype={
sex : "nan"
}
var ss = new test();
/*
ss¾ÍÏ൱ÓÚ
{
name : "nan",
__proto__ : {sex : "nan"}
}
*/
//¿ÉÒÔ²âÊÔÒ»ÏÂ
alert('-----------ÎÒÊÇ»ªÀöµÄ·Ö¸îÏß');
alert(ss.__proto__ === test.prototype); //¼ÇµÃÔÚfirefoxϲâÊÔ ieÏÂÎÞ·¨·ÃÎʵ½__proto__ ¿ÉÒÔ¿´µ½µ¯³öÀ´µÄÊÇtrue
 __proto__Õâ¸öÒ²µÃ½éÉÜÒ»ÏÂ,ËüÊǸöºÃ¶«Î÷.....
ÿ¸ö¶ÔÏóÔÚ³õʼ»¯µÄʱºò¶¼»áÓÐÕâôһ¸öÊôÐÔ;
Èç: (ÇëÔÚfirefoxϲâÊÔ)
var test ={};
alert(test.__proto__);  //¿ÉÒÔ¿´µ«µ¯³öµÄÊÇobj
µ±ÓÐÒ»¸ö¶ÔÏó ¼ÙÈçÊÇtest ;²éÕÒËûµÄaÊô


Ïà¹ØÎĵµ£º

µ÷ÓÃJavaScriptÎļþ

µ÷ÓÃJavaScriptÎļþ
ÓÃ×÷µ¼º½À¸
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> ......

JavaScriptµ÷ÓÃdataTable²¢»ñÈ¡ÆäÖµ(ASP.Net,VS2005)

JavaScriptµ÷ÓÃdataTable²¢»ñÈ¡ÆäÖµ(ASP.Net,VS2005)
     ±¾¹¦ÄÜÖ÷ÒªÓõ½http://www.cnblogs.com/Hdsome/archive/2008/06/26/1230177.htmlÕâ¸öÐֵܵĴúÂ룬ÎÒÖ÷ÒªÊÇ×öÕûÀíºÍÀ©Õ¹¡£
     Ê×ÏÈÔÚhttp://www.codeplex.com/AjaxPro/Release/ProjectReleases.aspx?ReleaseId=713ÍøÖ ......

javascript+css ʵÏÖtab¹¦ÄÜ

<!---------<html>
    <head>
        <style type="text/css">
.tabheader table {
  border-collapse: collapse; /* for IE */
  border-spacing: 0; /* for N6 */
}
.tabheader table tr td {mar ......

javascript¶ÁÈ¡xmlʵÏÖÓ¦ÓóÌÐò²Ëµ¥Ð§¹û

/*Ñùʽ*/
<style type="text/css">
    td{font-size:12px;}
    .item{text-decoration:none;width:100%;height:100%; line-height:22px;cursor:default;color:Black;vertical-align:middle}
    .staticTab{cursor:default;height:22px}
   ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ