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

ÁìÎò JavaScript Öеķ½·¨¶ÔÏó

ÎÄÕ³ö×Ô yiding-he.javaeye.com
JavaScript ÊÇÃæÏò¶ÔÏóµÄ¡£µ«ÊDz»ÉÙÈ˶ÔÕâÒ»µãÀí½âµÃ²¢²»È«Ãæ¡£
ÔÚ JavaScript ÖУ¬¶ÔÏó·ÖΪÁ½ÖÖ¡£Ò»ÖÖ¿ÉÒÔ³ÆΪ“ÆÕͨ¶ÔÏ󔣬¾ÍÊÇÎÒÃÇËùÆÕ±éÀí½âµÄÄÇЩ£ºÊý×Ö¡¢ÈÕÆÚ¡¢Óû§×Ô¶¨ÒåµÄ¶ÔÏó£¨È磺{}£©µÈµÈ¡£
»¹ÓÐÒ»ÖÖ£¬³ÆΪ“·½·¨¶ÔÏ󔣬¾ÍÊÇÎÒÃÇͨ³£¶¨ÒåµÄ function¡£Äã¿ÉÄܾõµÃÆæ¹Ö£º·½·¨¾ÍÊÇ·½·¨£¬Ôõô³ÉÁ˶ÔÏóÁË£¿µ«ÊÇÔÚ JavaScript ÖУ¬·½·¨µÄÈ·ÊDZ»µ±³É¶ÔÏóÀ´´¦ÀíµÄ¡£ÏÂÃæÊÇÒ»¸ö¼òµ¥µÄÀý×Ó£º
function func() {alert('Hello!');}
alert(func.toString());
ÔÚÕâ¸öÀý×ÓÖУ¬func ËäÈ»ÊÇ×÷Ϊһ¸ö·½·¨¶¨ÒåµÄ£¬µ«Ëü×ÔÉíÈ´°üº¬Ò»¸ö toString ·½·¨£¬ËµÃ÷ func ÔÚÕâÀïÊDZ»µ±³ÉÒ»¸ö¶ÔÏóÀ´´¦ÀíµÄ¡£¸ü׼ȷµÄ˵£¬func ÊÇÒ»¸ö“·½·¨¶ÔÏó”¡£ÏÂÃæÊÇÀý×ӵļÌÐø£º
func.name = “I am func.”;
alert(func.name);
ÎÒÃÇ¿ÉÒÔÈÎÒâµÄΪ func ÉèÖÃÊôÐÔ£¬Õâ¸ü¼ÓÖ¤Ã÷ÁË func ¾ÍÊÇÒ»¸ö¶ÔÏó¡£ÄÇô·½·¨¶ÔÏóºÍÆÕͨ¶ÔÏóµÄÇø±ðÔÚÄÄÀïÄØ£¿Ê×ÏÈ·½·¨¶ÔÏóµ±È»ÊÇ¿ÉÒÔÖ´Ðеģ¬ÔÚËüºóÃæ¼ÓÉÏÒ»¶ÔÀ¨ºÅ£¬¾ÍÊÇÖ´ÐÐÕâ¸ö·½·¨¶ÔÏóÁË¡£
func();
ËùÒÔ£¬·½·¨¶ÔÏó¾ßÓжþÖØÐÔ¡£Ò»·½ÃæËü¿ÉÒÔ±»Ö´ÐУ¬ÁíÒ»·½ÃæËüÍêÈ«¿ÉÒÔ±»µ±³ÉÒ»¸öÆÕͨ¶ÔÏóÀ´Ê¹Óá£ÕâÒâζ×ÅʲôÄØ£¿ÕâÒâζ×Å·½·¨¶ÔÏóÊÇ¿ÉÒÔÍêÈ«¶ÀÁ¢ÓÚÆäËû¶ÔÏó´æÔڵġ£ÕâÒ»µãÎÒÃÇ¿ÉÒÔͬ Java ±È½Ïһϡ£ÔÚ Java ÖУ¬·½·¨±ØÐëÔÚijһ¸öÀàÖж¨Ò壬¶ø²»Äܵ¥¶À´æÔÚ¡£¶ø JavaScript ÖоͲ»ÐèÒª¡£
·½·¨¶ÔÏó¶ÀÁ¢ÓÚÆäËû·½·¨£¬¾ÍÒâζ×ÅËüÄܹ»±»ÈÎÒâµÄÒýÓúʹ«µÝ¡£ÏÂÃæÊÇÒ»¸öÀý×Ó£º
function invoke(f) {
f();
}
invoke(func);
½«Ò»¸ö·½·¨¶ÔÏó func ´«µÝ¸øÁíÒ»¸ö·½·¨¶ÔÏó invoke£¬ÈúóÕßÔÚÊʵ±µÄʱºòÖ´ÐÐ func¡£Õâ¾ÍÊÇËùνµÄ“»Øµ÷”ÁË¡£ÁíÍ⣬·½·¨¶ÔÏóµÄÕâÖÖÌØÊâÐÔ£¬Ò²Ê¹µÃ this ¹Ø¼ü×Ö²»ÈÝÒ×°ÑÎÕ¡£Õâ·½ÃæÏà¹ØÎÄÕ²»ÉÙ£¬ÕâÀﲻ׸ÊöÁË¡£
³ýÁË¿ÉÒÔ±»Ö´ÐÐÒÔÍ⣬·½·¨¶ÔÏó»¹ÓÐÒ»¸öÌØÊâµÄ¹¦Ó㬾ÍÊÇËü¿ÉÒÔͨ¹ý new ¹Ø¼ü×ÖÀ´´´½¨ÆÕͨ¶ÔÏó¡£
»°ËµÃ¿Ò»¸ö·½·¨¶ÔÏó±»´´½¨Ê±£¬¶¼»á×Ô¶¯µÄÓµÓÐÒ»¸ö½Ð prototype µÄÊôÐÔ¡£Õâ¸öÊôÐÔ²¢ÎÞʲôÌرðÖ®´¦£¬ËüºÍÆäËûµÄÊôÐÔÒ»Ñù¿ÉÒÔ·ÃÎÊ£¬¿ÉÒÔ¸³Öµ¡£²»¹ýµ±ÎÒÃÇÓà new ¹Ø¼ü×ÖÀ´´´½¨Ò»¸ö¶ÔÏóµÄʱºò£¬prototype ¾ÍÆð×÷ÓÃÁË£ºËüµÄÖµ£¨Ò²ÊÇÒ»¸ö¶ÔÏó£©Ëù°üº¬µÄËùÓÐÊôÐÔ£¬¶¼»á±»¸´ÖƵ½Ð´´½¨µÄÄǸö¶ÔÏóÉÏÈ¥¡£ÏÂÃæÊÇÒ»¸öÀý×Ó£º
func.prototype.name=”prototype of func”;
var f = new func();
alert(f.name);
Ö´Ðе


Ïà¹ØÎĵµ£º

µ÷ÓÃ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 prototype

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

JavaScript»ù±¾ÊôÐÔ·½·¨²Î¿¼


JavaScript»ù±¾ÊôÐÔ·½·¨²Î¿¼
document.body.scrollTop  ·µ»ØºÍÉèÖõ±Ç°ÊúÏò¹ö¶¯ÌõµÄ×ø±êÖµ£¬ÐëÓ뺯ÊýÅäºÏ,
document.body.scrollLeft  ·µ»ØºÍÉèÖõ±Ç°ºáÏò¹ö¶¯ÎñµÄ×ø±êÖµ£¬ÐëÓ뺯ÊýÅäºÏ£¬
window.status=defaultStatus  ½«×´Ì¬À¸ÉèÖÃĬÈÏÏÔʾ
Obejct.innerHTML ¶ÔÏóObject±êÇ©ÖеÄhtmlÔ´´úÂë
Ob ......

JavaScriptʼþðÅÝÓ¦ÓÃʵÀý

ÔÚһЩ´«Í³µÄСÐÍWEBÓ¦Óÿª·¢¹ý³ÌÖУ¬JavaScriptͨ³£Ö»ÊÇÄÃÀ´×ö±íµ¥ÑéÖ¤¶øÒÔ£¬ËùÒÔÄãºÜÉÙ»áÓöµ½ÒòΪJavaScriptʼþðÅݶøÓ°Ï칦ÄܵÄʵÏÖÇé¿ö£¬ÓÖ»òÕßʼþðÅݶÔ×îÖÕʵÏÖЧ¹ûÓ°Ïì²»´ó£¬¿ÉºöÂÔ¡£È»¶ø£¬ÔÚ½ñÌìһЩ´óÐ͵ÄWEB½»»¥ÏîÄ¿ÖУ¬±ÈÈç´óÐ͵ÄWebGameÏîÄ¿£¬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" />
<title>ÍøÒ³¼ÆËãÆ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ