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

Javascript¼Ì³Ð»úÖÆ£¨call¡¢apply¡¢prototype£©

JavascriptµÄ¼Ì³Ð¿ÉÒÔͨ¹ýcall¡¢apply¡¢prototypeʵÏÖ¡£
1¡¢call£ºÔÚ×ÓÀàÖУ¬Óø¸Àà.call£¨this£¬arg0£¬arg1...£©¿ÉÒԼ̳и¸Àà¡£×¢ÒâcallµÄλÖ㬾¡Á¿ÔÚ×ÓÀàµÄµÚÒ»ÐУ¨js°´Ë³ÐòÖ´ÐУ¬·ÅÔÚºóÃæ¿ÉÄܶÔ×ÓÀàµÄÆäËûÊôÐÔ¡¢·½·¨ÓÐÓ°Ïì¡£±ÈÈç×ÓÀàºÍ¸¸ÀàÓÐÏàͬÃû×ֵķ½·¨£¬ºóÃæµÄ¸²¸ÇÇ°ÃæµÄ£©¡£
<html>
<head>
<title>call\apply\prototype test</title>
</head>
<script type="text/javascript">
//personÀà
function person(name, age) {
this.name = name;
this.age = age;
this.say = function() {
document.write("I am a person");
}
this.display = function() {
document.write(this.name + "-" + this.age);
}
}
//studentÀ࣬¼Ì³Ð×Ôperson
function student(name, age, no) {
person.call(this, name, age);//personÖеÄthisµÈÓÚ²ÎÊýÖеÄthis£¬¼´studentÖеÄnameºÍage
this.no = no;
this.display = function() {//¸²¸ÇÁ˸¸ÀàµÄ·½·¨
document.write(this.name + "-" + this.age + "-" + this.no);
}
}
//´´½¨personÀà
var p = new person("captain", 21);
p.display();//captain-21
p.say();//I am a person
//´´½¨studentÀà
var s = new student("captain", 21, "06281097")
s.display();//captain-21-06281097
s.say();//I am a person ¼Ì³ÐÁ˸¸ÀàµÄ·½·¨
<script>
<body>
</body>
</html>
2¡¢apply£ºÔÚ×ÓÀàÖУ¬Óø¸Àà.apply£¨this£¬args£©¿ÉÒԼ̳и¸ÀࣨargsΪ²ÎÊýÊý×飩¡£
<html>
<head>
<title>call\apply\prototype test</title>
</head>
<script type="text/javascript">
//personÀà
function person(name, age) {
this.name = name;
this.age = age;
this.say = function() {
document.write("I am a person");
}
this.display = function() {
document.write(this.name + "-" + this.age);
}
}
//studentÀ࣬¼Ì³Ð×Ôperson
function student(name, age, no) {
person.apply(this, new Array(name, age));//Óëcall²»Í¬µÄÊÇ£¬apply´«µÝµÄÊÇÊý×é
this.no = no;
this.display = function() {//¸²¸ÇÁ˸¸ÀàµÄ·½·¨
document.write(this.name + "-" + this.age + "-" + this.no);
}
}
//´´½¨pe


Ïà¹ØÎĵµ£º

JavaScriptµ÷ÓÃÏÖ³ÉWordÄ£°åÍê³É´òÓ¡

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>JSµ÷ÓÃÏÖ³ÉWordÄ£°åÍê³É´òÓ¡</title>
    <script type="text/javascript">
      //ת»»wordµÄº¯Êý
      function ......

ÍÆ¼ö9¿îºÜ°ôµÄÍøÒ³»æÖÆÍ¼±íJavaScript¿ò¼Ü½Å±¾


    ½ñÌìÒªÏò´ó¼ÒÍÆ¼ö9¿îºÜ°ôµÄ¿ÉÔÚÍøÒ³ÖлæÖÆÍ¼±íµÄJavaScript½Å±¾£¬ÕâЩÓÐȤµÄJS½Å±¾¿ÉÒÔ°ïÖúÄã¿ìËÙ·½±ãµÄ»æÖÆÍ¼±í£¨Ïß¡¢Ãæ¡¢±ý¡¢Ìõ…£©£¬ÆäÖаüÀ¨jQuery¡¢MooTools¡¢PrototypeºÍһЩÆäËüµÄJavaScript¿ò¼Ü¡£

Äú»¹¿ÉÒԲο¼ÒÔÏÂJavaScript/CSSÏà¹Ø½Ì³Ì¼°×ÊÔ´:


¡¶¾«Ñ¡30¸öÓÅÐãµÄCSS¼¼Ê ......

javascriptÖ®±íµ¥ÑéÖ¤ ÍêÃÀÌáÉýÓû§ÌåÑé

ÒýÑÔ
Ôö¼Ó¿Í»§¶ËµÄ±íµ¥ÑéÖ¤¿ÉÒÔΪÓû§Ìṩ¸ü¿ìµÄÌåÑ飬µ«¾ö²»ÄܺöÊÓµÄÊÇ£¬¿Í»§¶Ë±íµ¥ÑéÖ¤ÓÀÔ¶²»Ó¦¸ÃÈ¡´ú·þÎñÆ÷¶ËµÄÑéÖ¤£¬¶øÖ»ÄÜÊǸ¨ÖúºÍÔöÇ¿¡£¸ù¾Ý¾­ÑéJavaScriptÑéÖ¤±íµ¥»ù±¾·ÖΪÒÔϼ¸·½ÃæµÄÄÚÈÝ£¬±ØÌî×ֶΡ¢ÌØÊâģʽƥÅäµÈ£¬»¹Òª×¢Òâ´íÎóµÄÌáʾ·½Ê½¶ÔÒ»¸ö±íµ¥µÄ¿ÉÓÃÐÔÓÐ׿«ÆäÖØÒªµÄÓ°Ïì¡£
2½¨Á¢±íµ¥
  &nb ......

JavascriptʵÏÖGridViewÎÞË¢ÐÂÑ¡ÔñÒ»ÐÐ

ÓÃJavascript¿ÉÒÔʵÏÖ¶ÔGridViewÖÐijһÐÐÑ¡Ôñ£¬¶øÎÞÐè½øÐÐÒ³ÃæµÄˢС£
Ê×ÏÈÒªÔÚGridViewµÄonrowdataboundµÄevent handlerÖÐΪGridViewÖеÄÿһÐÐonclick°ó¶¨event handler (Javascript)¡£¼ÙÈçGridView´úÂëÈçÏ£º
        <asp:GridView runat="server" id="GridViewCategory" Aut ......

JavaScriptº¯Êý


http://xiayuanfeng.javaeye.com/blog/£¨Ô­ÎÄ£©
ʲôÊǺ¯Êý(Function)
function sum(a,b){  
     return a+b;  
}  
ÆäʵͨË×µÄ˵¾ÍÊÇÒ»¸öÓÐÃû³ÆµÄ´úÂë¶Î£¬·½±ãÖØÓá£
ҪעÒâµÄÊÇ£º
1.Javascript µÄº¯ÊýÓï·¨£¬ÒòΪJavascript±¾Éí¾ÍÊÇÇø·Ö´óСдµÄ£¬ËùÒÔfunction²»ÄÜд×÷Function»ò ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ