javascript ѧϰ±Ê¼Ç£¨5£© ¼Ì³Ð
1. ijЩ»ùÀàÈç¹û²»Ö±½ÓʹÓÃ,¶ø½ö½öÖ»ÊÇÓÃÓÚ¸ø×ÓÀàÌṩͨÓõĺ¯Êý,ÕâÖÖÇé¿öÏÂ,»ùÀà±»¿´×÷³éÏóÀà.
2. ÔÚ javascript µÄÀàÖÐËùÓеķ½·¨ºÍÊôÐÔ¶¼ÊÇ"¹«ÓõÄ".
3. javascript Öеļ̳в¢²»ÊÇÃ÷È·¹æ¶¨µÄ,¶øÊÇͨ¹ýÄ£·ÂÀ´ÊµÏÖµÄ.ÓÐÒÔÏ·½·¨:
(1). ¶ÔÏóð³ä
function A(sColor){
this.color = sColor;
this.showColor = function(){
alert(this.color);
};
}
function B(sColor,sName){
this.newMethod = A;
this.newMethod(sColor);
delete this.newMethod;
this.name = sName; //Ðµķ½·¨ºÍÊôÐÔÒªÔÚɾ³ýÁËз½·¨µÄ¶¨ Òåºó¶¨Òå
this.showName = function(){
alert(this.name);
};
}
¶ÔÏóð³ä·½·¨¿ÉÒÔÖ§³Ö¶àÖØÀà¼Ì³Ð,Ò²¾ÍÊÇÒ»¸öÀà¿ÉÒԼ̳ÐÓÚ¶à¸öÀà
Èç¹û´æÔÚÒ»¸öÀà C Ïë¼Ì³ÐÀà A ºÍ B,Ö»ÒªÕâÑù:
function C(){
this.newMethod = A;
this.newMethod();
delete this.newMethod
this.newMethod = B;
this.newMethod();
delete this.newMethod
}
µ«ÊÇҪעÒâÈç¹û A ºÍ B ÖдæÔÚͬÃûµÄÊôÐÔ»òÕß·½·¨,Ôò B ¾ßÓиßÓÅÏȼ¶,ÒòΪËûÊǺóÃæµÄÀà¼Ì³Ð.
(2). call() ·½·¨
function B(sColor,sName){
//this.newMethod = A;
//this.newMethod(sColor);
//delete this.newMethod;
A.call(this,sColor);
this.name = sName;
this.showName = function(){
alert(this.name);
};
}
(3). apply() ·½·¨
function B(sColor,sName){
//this.newMethod = A;
//this.newMethod(sColor);
//delete this.newMethod;
A.apply(this,new Array(sColor));
this.name = sName;
this.showName = function(){
alert(this.name);
};
}
(4). ÔÐÍÁ´,ÔÐÍÁ´²»Ö§³Ö¶àÖØ¼Ì³Ð
function A(){
}
A.p
Ïà¹ØÎĵµ£º
1. javascript ÊÇÇø·Ö´óСдµÄ£¬°üÀ¨±äÁ¿¡¢º¯ÊýÃûµÈµÈ¡£
2. javascript ÖеıäÁ¿ÊÇÈõÀàÐ͵쬶¨Òå±äÁ¿Ê±Ö»Óà var ÔËËã·û¡£
var test1 = "hi";
»òÕß
var test1 = "hi",test2 = "hello";
»òÕß(¿ÉÒÔÊDz»Í¬µÄÀàÐÍ)
var test1 = "hi",test2 = 12;
»òÕß(¿ÉÒÔ²»Óóõʼ»¯)
var test1;
3. javascript ÿÌõÓï¾äµÄ½áβ&ldqu ......
1.document.formName.item('itemname')µÄÎÊÌâ
˵Ã÷£ºIEÏ¿ÉÒÔʹÓÃdocument.formName.item('itemname')ºÍdocument.formName.elements('elementsName');
FFÏÂÖ»ÄÜʹÓÃdocuement.formName.elements('elementsName');
½â¾ö·½·¨£ºÍ³Ò»Ê¹ÓÃdocuement.formName.elements('elementsName');
2.¼¯ºÏÀà¶ÔÏóÎÊÌâ
˵Ã÷£ºIEÏ¿ÉÒÔʹÓÃ[]ºÍ ......
JavaScript For Ñ»·
Previous Page
Next Page
JavaScript ÖеÄÑ»·ÓÃÀ´½«Í¬Ò»¶Î´úÂëÖ´ÐÐÖ¸¶¨µÄ´ÎÊý£¨»òÕßµ±Ö¸¶¨µÄÌõ¼þΪ true ʱ£©¡£
ʵÀý
For Ñ»· ÈçºÎ±àд loop Ñ»·À´°´ÕÕÖ¸¶¨µÄ´ÎÊýÖ´ÐÐÏàͬµÄ´úÂë¡£ Ñ»·²úÉú HTML ±êÌâ ÈçºÎʹÓÃLoopÑ»·À´²úÉú²»Í¬µÄHTML±êÌâ¡£
JavaScript Ñ»·
ÔÚ±àд´úÂëʱ£¬Äã³£³£Ï£Íû· ......
<script language="javascript" type="text/javascript">
// <!CDATA[
function Test()
{
document.location.href = 'test. ......
//¹ýÂËÁ½¶ËµÄ¿Õ¸ñ
function trim(str){
return str.replace(/(^\s*)|(\s*$)/g, "");
}
//¹ýÂË×ó±ßµÄ¿Õ¸ñ
function ltrim(str){
return  ......