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

javaScriptÑ­Ðò½¥½ø£¨3£©


<!--
@page { margin: 2cm }
P { margin-bottom: 0.21cm }
-->
±Õ°ü£¨
closure
£©
±Õ°üÒâζ×ÅÄÚ²ãµÄº¯Êý¿ÉÒÔÒýÓôæÔÚÓÚ°üΧËûµÄº¯ÊýÄڵıäÁ¿£¬¼´Ê¹Íâ²ãº¯ÊýµÄÖ´ÐÐÒѾ­ÖÕÖ¹¡£Õâ¸öÌØÐԷdz£Ç¿´óºÍ¸´ÔÓ¡£
 
ÀýÈ磺±Õ°üÈçºÎʹ´úÂë¸üÇåÎúµÄÁ½¸öÀý×Ó
ÕÒ³ö
ID
Ϊ‘
main’
µÄÔªËØ
var
obj=document.getElementById("main");
ÐÞ¸ÄËüµÄ
border
Ñùʽ
obj.style.border = "1px solid
red";
³õʼ»¯Ò»¸öÔÚÒ»ÃëºóÖ´ÐеĻص÷º¯Êý
(callback)
setTimeout(function(){

Ëý½«Òþ²Ø´Ë¶ÔÏó
obj.style.display = 'none';
},1000);
 
Ò»¸öÓÃÓÚÑÓʱÏÔʾ¾¯¸æÐÅÏ¢µÄͨÓú¯Êý
function delayedAlert(msg, time){
³õʼ»¯Ò»¸ö·â×°µÄ»Øµ÷º¯Êý
setTimeout(function(){

Ëý½«°üº¬±¾º¯ÊýµÄÍâΧº¯Êý´«ÈëµÄ
msg
±äÁ¿
alert(msg);
},time);
}
 
ÓÃÁ½¸ö²ÎÊýµ÷ÓÃ
delayedAlert
º¯Êý
delayedAlert("zhangxinagrong",2000);
 
ÔÚһЩº¯Êýʽ³ÌÐòÉè¼ÆÓïÑÔÀÓÐÒ»ÖÖ³ÆΪ
Curry
»¯µÃ¼¼Êõ¡£±¾ÖÊÉÏ£¬
Curry
»¯ÊÇÒ»ÖÖͨ¹ý°Ñ¶à¸ö²ÎÊýÌî³äµ½º¯ÊýÌåÖУ¬ÊµÏÖ½«º¯Êýת»»ÎªÒ»¸öеľ­¹ý¼ò»¯µÄ£¨Ê¹Ö®½ÓÊܵIJÎÊý¸üÉÙ£©º¯ÊýµÄ¼¼Êõ¡£
 
ÀýÈ磺ÓñհüʵÏֵĺ¯Êý
Curry
»¯
Êý×ÖÇóºÍº¯ÊýµÄº¯ÊýÉú³ÉÆ÷
function addGenerator(num){
·µ»ØÒ»¸ö¼òµ¥µÄº¯Êý£¬ÇóÁ½¸öÊý×ֵĺͣ¬ÆäÖеÚÒ»¸öÊý×ÖÀ´×ÔÉú³ÉÆ÷
return function(toAdd){
return num + toAdd;
};
}
addFive
ÏÖÔÚ°üº¬Ò»¸ö½ÓÊܵ¥Ò»²ÎÊýµÄº¯Êý£¬Õâ¸öº¯ÊýÄÜÇóµÃ
5
¼ÓÉϸòÎÊýµÄºÍ
var addFive = addGenerator(5);
ÕâÀïÎÒÃÇ¿ÉÒÔ¿´µ½£¬ÔÚ´«Èë²ÎÊýΪ
4
ʱ£¬
addFive
º¯ÊýµÄ½á¹ûÊÇ
9
alert(addFive(4)==9);
 
±Õ°ü»¹Äܽâ¾öÁíÒ»¸ö³£¼û
JavaScript
±àдÎÊÌâ¡£
ͨ¹ý×ÔÖ´ÐеÄÄäÃûº¯ÊýÄã¿ÉÒÔ°ÑËùÓÐÔ­±¾ÊôÓÚÈ«¾ÖµÄ±äÁ¿¶¼Òþ²ØÆðÀ´¡£
 
ÀýÈ磺ʹÓÃÄäÃûº¯ÊýÀ´Òþ²ØÈ«¾Ö×÷ÓÃÓò±äÁ¿µÄÀý×Ó
´´½¨Ò»¸öеÄÄäÃûº¯Êý£¬×÷Ϊ°ü×°
(function(){
±äÁ¿Ô­±¾Ó¦¸ÃÊÇÈ«¾ÖµÄ
var msg = "Thanks
zhangxiangrong";
½«Ò»¸öк¯Êý°ó¶¨µ½È«¾Ö¶ÔÏó
window.onunload = function(){
Õâ¸öº¯ÊýʹÓÃÁË“Òþ²Ø”µÄ
msg
±äÁ¿
alert(msg);
};
¹Ø±ÕÄäÃûº¯Êý²¢Ö´ÐÐÖ®
})();
 
±Õ°üµÄ¸ÅÄî²»ÈÝÒ×Àí½âºÍÕÆÎÕ¡£
ÍƼöһƪ¾«²ÊµÄ½âÊÍ
JavaScript
µÄ±Õ°üÊÇÈçºÎ¹¤×÷µÄÎÄÕ£º
Jim
Jey
µÄ


Ïà¹ØÎĵµ£º

JavaScriptʹÓ÷½·¨ºÍ¼¼ÇÉ´óÈ«

JavaScript¾ÍÕâô»ØÊ£º»ù´¡ÖªÊ¶
1 ´´½¨½Å±¾¿é
1: <script language="JavaScript">
2: JavaScript code goes here
3: </script>
¡¡
2 Òþ²Ø½Å±¾´úÂë
1: <script language="JavaScript">
2: <!--
3: document.write("Hello");
4: // -->
5: </script>
ÔÚ²»Ö§³ÖJavaScriptµÄä¯ÀÀ ......

JAVASCRIPT ½Ì³Ì2 ¸¶Ê×ê¿

 
µÚ 2 ¼¯
--------------------------------------------------------------------------------
·¶ Àý 5£º
ÔÚ Õâ Ò» ²¿ ·Ö Ê× ÏÈ Òª Ϊ Äã Õ¹ ʾ µÄ JavaScript ÌØ ÐÔ ÊÇ ½« Äã µÄ »¬ Êó ÒÆ µ½ Õâ ¸ö ²» ͬ ÑÕ É«
µÄÁ¬ ½áÉÏ Ã棬 ´Ë ʱ ¿´ ¿´ ä¯ ÀÀ Æ÷ Ï µÄ ×´ ̬ ÁÐ ÓÐ ºÎ ½á ¹û¡£ È» áá Õâ Ñù µÄ ¹¦ ÄÜ ÎÒ ÃÇ ......

JAVASCRIPT ½Ì³Ì4 ¸¶Ê×ê¿

µÚËļ¯
--------------------------------------------------------------------------------
ÕâÕÂÎÒ½«¸æËßÄúÈçºÎÔÚ״̬ÁÐ (statusbar) (Ò²¾ÍÊÇÄúä¯ÀÀÆ÷×îÏ·½ÏÔʾ URLs µÄÄÇÒ»ÐÐ) ÏÔʾÎÄ×Ö£¬²¢ÇÒ½«½ÌÄú 'ÅÜÂíµÆ' (ÒÔϼò³Æ scroller ) µÄ¹¤×÷Ô­Àí¡£ËäÈ»ÒÔ
JavaScript Íê³ÉµÄ scroller Ä¿Ç°ÈÔÓÐЩÎÊÌâ (ÉÔáá»áÌáµ½ÎÊÌâÔ ......

flashÓëjavascriptµÄ½»»¥


flashÓëjavascriptµÄ½»»¥¿ÉÄÜÌÖÂ۵ıȽ϶à,½ñÌìΪ´ó¼Ò½éÉÜÏÂÈçºÎʹÓÃflexÓëjavascript½øÐн»»¥
Ò»¡¢ÔÚJavaScriptÖе÷ÓÃFlex·½·¨
ÔÚFlexÖпÉÒÔÓÃExternalInterfaceÀ´µ÷ÓÃFlexµÄ·½·¨£¬Í¾¾¶ÊÇ
1.ͨ¹ýÔÚFlexÓ¦Óÿɵ÷Ó÷½·¨ÁбíÖÐÌí¼ÓÖ¸¶¨µÄ¹«Ó÷½·¨¡£ÔÚFlexÓ¦ÓÃÖÐͨ¹ýµ÷ÓÃaddCallback()¿ÉÒÔ°ÑÒ»¸ö·½·¨Ìí¼Óµ½´ËÁбíÖС£addC ......

javascript¿´Ô´´úÂë

<HTML>
<HEAD>
<META http-equiv='Content-Type' content='text/html; charset=gb2312'>
<TITLE>Óð´Å¥ÏÔʾԴ´úÂë»òÕßjavascriptÀïÃæµÄÄÚÈÝ£¬ÓÐʱ»áÓÐ</TITLE>
</HEAD>
<BODY >
<script id=abc >
function dennisboys()
{
var i=0;
alert(document.documentElem ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ