Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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 ²Ù×÷¹â±ê

°æ±¾£ºDHTML Object Model¡¡·µ»ØÖµ£ºÓÐ
Óï·¨£º
oTextRange = object . createTextRange ()
²ÎÊý£º
ÎÞ
·µ»ØÖµ£º
oTextRange : ¶ÔÏó(Element)¡£Èç¹û³É¹¦µÄ»°·µ»Ø±»½¨Á¢µÄ TextRange ¶ÔÏó¡£
˵Ã÷£º
Ϊ object ½¨Á¢ TextRange ¶ÔÏó¡£
ʹÓÃ´Ë TextRange ¶ÔÏó¿ÉÒÔ¼ìË÷ºÍÐÞ¸Ä object ÄÚµÄÎı¾¡£ TextRange ¶ÔÏ ......

ÉèΪÊ×Ò³ºÍÌí¼ÓÊղصÄJavascript´úÂë

ÉèΪÊ×Ò³ºÍÌí¼ÓÊղصÄJavascript´úÂ룬¼æÈÝÐÔ»¹¿ÉÒÔ£¬¸÷ÖÖÖ÷Á÷ä¯ÀÀÆ÷¶¼²âÊÔͨ¹ýÁË¡£
function addfavorite(){//¼ÓÈëÊÕ²Ø
if (document.all){
window.external.addFavorite("http://"+document.location.host+"/",document.title);
}else if (window.sidebar){
window.sidebar.addPanel(document.tit ......

ÅäºÏjavascript¶¯Ì¬²Ù×÷±íÍ·

Õâ¶Îʱ¼äÔÚÓÃdisplayTag, ËüÓкܶàºÃÓõŦÄÜ,°³Ò²²»¾ÍÔÚÕâ׸Êö,µ±È»Ò²Óм¸¸ö²»·½±ãµÄµØ·½. ±ÈÈçÇóºÍºó"%"µÄÏÔʾµÈÓëÇóºÍÏà¹ØµÄȱµã, ÕâÀïÏȽéÉÜÒ»¸öȱµã²¢°ÑÎÒ´ÓÍøÉÏÕûÀí³öÀ´µÄ½â¾ö·½°¸Ò²Ò»²¢Ìû³ö. ÎÊÌâÊÇÕâÑùµÄ: ÓÉÓÚÒµÎñÒªÇó, µ±Óû§Êó±êλÓÚ±íÖÐijһÁеıêͷʱ, ÔÚÕâ¸ö±íÍ·"¶¯»­"µØÏÔʾÕâÁеļò½é. ÏÈ¿´ÏÂ×ö³öÀ´µÄЧ¹û: ......

¹ØÓÚjavascriptÄÚ´æй¶

<html>
<body>
<script type="text/JScript">
for (i=0; i<10000; i++) {    // this loop enforces the effect
    var model = new Object();
    var element = document.createElement("<br>");
    model.myElement = ......

JavaScript³£ÓôúÂë

1:js ×Ö·û´®³¤¶ÈÏÞÖÆ¡¢ÅжÏ×Ö·û³¤¶È¡¢jsÏÞÖÆÊäÈë¡¢ÏÞÖƲ»ÄÜÊäÈë¡¢textarea ³¤¶ÈÏÞÖÆ
2.:jsÅжϺº×Ö¡¢ÅжÏÊÇ·ñºº×Ö ¡¢Ö»ÄÜÊäÈ뺺×Ö
3:jsÅжÏÊÇ·ñÊäÈëÓ¢ÎÄ¡¢Ö»ÄÜÊäÈëÓ¢ÎÄ
4:jsÖ»ÄÜÊäÈëÊý×Ö,ÅжÏÊý×Ö¡¢ÑéÖ¤Êý×Ö¡¢¼ì²âÊý×Ö¡¢ÅжÏÊÇ·ñΪÊý×Ö¡¢Ö»ÄÜÊäÈëÊý×Ö
5:Ö»ÄÜÊäÈëÓ¢ÎÄ×Ö·ûºÍÊý×Ö
6: js emailÑéÖ¤ ¡¢js ÅжÏemail ¡¢ÐÅÏä ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ