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

JavaScriptʼþðÅݼò½é¼°Ó¦ÓÃ



          
Ò»¡¢Ê²Ã´ÊÇʼþðÅÝ
ÔÚÒ»¸ö¶ÔÏóÉÏ´¥·¢Ä³Ààʼþ£¨±ÈÈçµ¥»÷onclickʼþ£©£¬Èç¹û´Ë¶ÔÏó¶¨ÒåÁË´ËʼþµÄ´¦Àí³ÌÐò£¬ÄÇô´Ëʼþ¾Í»áµ÷ÓÃÕâ¸ö´¦Àí³ÌÐò£¬Èç¹ûûÓж¨Òå´ËÊ ¼þ´¦Àí³ÌÐò»òÕßʼþ·µ»Øtrue£¬ÄÇôÕâ¸öʼþ»áÏòÕâ¸ö¶ÔÏóµÄ¸¸¼¶¶ÔÏó´«²¥£¬´ÓÀïµ½Í⣬ֱÖÁËü±»´¦Àí£¨¸¸¼¶¶ÔÏóËùÓÐͬÀàʼþ¶¼½«±»¼¤»î£©£¬»òÕßËüµ½´ïÁË¶Ô Ïó²ã´ÎµÄ×²ã£¬¼´document¶ÔÏó£¨ÓÐЩä¯ÀÀÆ÷ÊÇwindow£©¡£
´ò¸ö±È·½Ëµ£ºÄãÔڵط½·¨ÔºÒªÉÏËßÒ»¼þ°¸×Ó£¬Èç¹ûµØ·½Ã»Óд¦Àí´ËÀà°¸¼þµÄ·¨Ôº£¬µØ·½Ïà¹Ø²¿ÃÅ»á°ïÄã¼ÌÐøÍùÉϼ¶·¨ÔºÉÏËߣ¬±ÈÈç´ÓÊ춵½Ê¡¼¶£¬Ö±ÖÁµ½ÖÐÑë·¨Ôº£¬×îÖÕʹÄãµÄ°¸¼þµÃÒÔ´¦Àí¡£
¶þ¡¢Ê¼þðÅÝÓÐʲô×÷ÓÃ
£¨1£©Ê¼þðÅÝÔÊÐí¶à¸ö²Ù×÷±»¼¯Öд¦Àí£¨°Ñʼþ´¦ÀíÆ÷Ìí¼Óµ½Ò»¸ö¸¸¼¶ÔªËØÉÏ£¬±ÜÃâ°Ñʼþ´¦ÀíÆ÷Ìí¼Óµ½¶à¸ö×Ó¼¶ÔªËØÉÏ£©£¬Ëü»¹¿ÉÒÔÈÃÄãÔÚ¶ÔÏó²ãµÄ²»Í¬¼¶±ð²¶»ñʼþ¡£
¡¾¼¯Öд¦ÀíÀý×Ó¡¿
<div onclick=”eventHandle(event)” id=”outSide” style=”width:100px; height:100px; background:#000; padding:50px”>
<div id=”inSide” style=”width:100px; height:100px; background:#CCC”></div>
</div>
<script type=”text/javascript”>
//±¾Àý×ÓÖ»ÔÚÍâÃæºÐ×Ó¶¨ÒåÁË´¦Àí·½·¨£¬¶øÕâ¸ö·½·¨Ò»Ñù¿ÉÒÔ²¶»ñµ½×ÓÔªËصã»÷ÐÐΪ²¢´¦ÀíËü¡£¼ÙÉèÓгÉǧÉÏÍò×ÓÔªËØÒª´¦Àí£¬ÄѵÀÎÒÃÇҪΪÿ¸öÔªËؼӓonclick=”eventHandle(event)””£¿ÏÔȻûÓÐÕâÖÖ¼¯Öд¦ÀíµÄ·½·¨À´µÄ¼òµ¥£¬Í¬Ê±ËüµÄÐÔÄÜÒ²ÊǸü¸ßµÄ¡£
function eventHandle(e){
   var e=e||window.event;
   var obj=e.target||e.srcElement;
   alert(obj.id+‘ was click‘)
}
</script>
£¨2£©Èò»Í¬µÄ¶ÔÏóͬʱ²¶»ñͬһʼþ£¬²¢µ÷ÓÃ×Ô¼ºµÄרÊô´¦Àí³ÌÐò×ö×Ô¼ºµÄÊÂÇ飬¾ÍÏñÀÏ°åÒ»ÏÂÃüÁ¸÷×ÔÔ±¹¤×ö×Ô¼º¸ÚλÉϵŤ×÷È¥ÁË¡£
¡¾Í¬Ê±²¶»ñͬһʼþÀý×Ó¡¿
<div onclick=”outSideWork()” id=”outSide” style=”width:100px; height:100px; background:#000; padding:50px”>
<div onclick=”inSideWork()” id=”inSide” style=”width:100px; height


Ïà¹ØÎĵµ£º

JavaScript ½âÎö¶ÁÈ¡XMLÎĵµ


JavaScript½âÎö¶ÁÈ¡XMLÎļþ£¬Ö÷Òª¾ÍÊǼÓÔز¢½âÎöXMLÎļþ£¬È»ºó¾Í¿ÉÒÔ²âÊÔ½âÎöµÄXMLÎļþµÄÄÚÈÝ£¬´òÓ¡Êä³öÀ´¡£
±àдÁËÒ»¸öJavaScriptµÄÀàÀ´ÊµÏÖ¶ÁÈ¡Ò»¸öXMLÎļþÖеÄÊý¾Ý£¬ÊµÏÖ´úÂëÈçÏÂËùʾ£º
<mce:script type="text/javascript"><!--

/**
* @author Shirdrn
*/
function XMLDoc(){}; // ¶¨ÒåÒ»¸öXM ......

javascriptÌí¼ÓнڵãµÄ·½·¨

//´´½¨Ò»¸öеÄÔªËؽڵ㣬ԪËØÃûʹÓÃsTagName¶¨Òå
oElementNode = document.createElementNode(sTagName);
//´´½¨Ò»¸öеĽڵ㣬½ÚµãÃûʹÓÃsTextValue¶¨Òå
oTextNode = document.createTextNode(sTextValue);
//ΪԪËظ³Ò»¸öеÄÊôÐÔ£¬ÊôÐÔÃûʹÓÃsName
oAttribute = document.createAttribute(sName);
//´´½¨Ò»¸öÐ嵀 ......

JavaScript£¬µÈ±ÈÀýËõ·ÅͼƬµÄº¯Êý

<script language="JavaScript">
<!--
//ͼƬ°´±ÈÀýËõ·Å
var flag=false;
function DrawImage(ImgD,iwidth,iheight){
    //²ÎÊý(ͼƬ,ÔÊÐíµÄ¿í¶È,ÔÊÐíµÄ¸ß¶È)
    var image=new Image();
    image.src=ImgD.src; ......

javascript²¶»ñ´°¿Ú¹Ø±Õʼþ


javascript²¶»ñ´°¿Ú¹Ø±ÕʼþÓÐÁ½ÖÖ·½·¨
1.ÓÃjavascriptÖØж¨Òå window.onbeforeunload()  ʼþ
ÔÚjavascriptÀﶨÒåÒ»¸öº¯Êý¼´¿É
function  window.onbeforeunload()  {  alert("¹Ø±Õ´°¿Ú")}
alert()ʼþ½«»áÔڹرմ°¿ÚÇ°Ö´ÐУ¬ÄãÒ²¿ÉÒÔÓû§¾ö¶¨ÊÇ·ñ¹Ø±Õ´°¿Ú
function  window.o ......

ÉîÈëÀí½âJavaScript±Õ°ü(closure)


ת×Ô£ºhttp://www.felixwoo.com/?s=%E9%97%AD%E5%8C%85
ÉîÈëÀí½âJavaScript±Õ°ü(closure)
·¢±íÓÚ: 14:48 | ·ÖÀà: ¿ª·¢¼¼Êõ | ÆÀÂÛ: 25 | ÈËÆø: 6,114 |
×î½üÔÚÍøÉϲéÔÄÁ˲»ÉÙJavascript±Õ°ü(closure)Ïà¹ØµÄ×ÊÁÏ£¬Ð´µÄ´ó¶àÊǷdz£µÄѧÊõºÍרҵ¡£¶ÔÓÚ³õѧÕßÀ´Ëµ±ð˵Àí½â±Õ°üÁË£¬¾ÍÁ¬ÎÄ×ÖÐðÊö¶¼ºÜÄÑ¿´¶®¡£×«Ð´´ËÎĵÄÄ¿µÄ¾ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ