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

Javascriptʼþ°ó¶¨µÄ¼¸ÖÖ·½Ê½£¨°Ù¶Èµç»°ÃæÊÔÌ⣩

 JavascriptµÄʼþ°ó¶¨Ö÷ÒªÓÐËÄÖÖ·½·¨£¨Ò»ÏÂÔÚIEÖÐÔËÐÐÕý³££¬µ«²»±£Ö¤ÆäËûä¯ÀÀÆ÷£©£º
  [×¢£ºonXXXΪijһʼþ£¬funΪijһfunction£¬domIdΪijһDOM¶ÔÏóid£¬eventÀàÐͼûºó±ß¸½Â¼¡£]
1¡¢ÔÚDOMÖУ¬Ö±½ÓÓÃonXXX="fun();"½øÐа󶨠
2¡¢ÔÚJavascript´úÂëÖÐÓà DOM¶ÔÏó.onXXX=fun ½øÐаó¶¨
3¡¢Óà DOM¶ÔÏó.attachEvent("onXXX",fun) ½øÐаó¶¨
4¡¢ÓÃ<script for="domId" event="onXXX">fun();</script> ½øÐаó¶¨
<html>
<head>
<title>event test</title>
</head>
<body onload="init()">
<!-- °ó¶¨·½Ê½Ò»:ÔÚÔªËØÖУ¬Í¨¹ýonXXX£¨Ê¼þ£©ÉèÖð󶨷½·¨ -->
<button id="btn1" onclick="display()" >°ó¶¨·½Ê½Ò»</button>
<!-- °ó¶¨·½Ê½¶þ£ºÔÚJavascript´úÂëÖУ¬Í¨¹ý»ñµÃÔªËØ£¬ÎªÔªËصÄonXXX£¨Ê¼þ£©ÉèÖð󶨷½·¨ -->
<button id="btn2">°ó¶¨·½Ê½¶þ</button>
<!-- °ó¶¨·½Ê½Èý£ºÍ¨¹ýfor¡¢eventΪԪËØ°ó¶¨Ê¼þ£¨IE4+£©¡£forºóÃæÊÇÔªËØid£¬eventÊǾßÌåʼþ -->
<button id="btn3">°ó¶¨·½Ê½Èý</button>
<!-- °ó¶¨·½Ê½ËÄ£ºÍ¨¹ýattachEventΪԪËØ°ó¶¨Ê¼þ£¨IE5+£©¡£µÚÒ»¸ö²ÎÊýÊÇʼþÃû£¬µÚ¶þ¸ö²ÎÊýÊǰ󶨵ķ½·¨ -->
<button id="btn4">°ó¶¨·½Ê½ËÄ</button>
</body>
</html>
<script type="text/javascript">
function init() {
document.getElementById("btn2").onclick = display;//Ϊbutton2°ó¶¨Ê¼þ
document.getElementById("btn4").attachEvent("onclick", display);//Ϊbutton4°ó¶¨Ê¼þ
}
function display(event) {
var targ;//´¥·¢Ê¼þµÄ¶ÔÏóÒýÓÃ
if (!event) {
var event = window.event;//»ñµÃµ±Ç°Ê¼þ(IE)
}
if (event.target) {//IEûÓÐtarget
targ = evente.target;
} else if (event.srcElement) {//ÊÊÓÃÓÚIE
targ = event.srcElement;
}
//¶Ô´¥·¢Ê¼þµÄ¶ÔÏó½øÐвÙ×÷
alert(targ.tagName+"-"+targ.id+"-"+event.x+"-"+event.offsetX);
targ.disabled="disabled" ;
}
<script>
<script for="btn3" event="onclick">
display();//Ϊbutton3°ó¶¨Ê¼þ
<script>
¸½Ò»£ºeventʼþ£º
onabort£º ͼÏñµÄ¼ÓÔر»ÖжÏ
onblur£º ÔªËØʧȥ½¹µã
onchange£º ÓòµÄÄÚÈݱ»¸Ä±ä
onclick£º µ±Óû§µã»÷ij¸


Ïà¹ØÎĵµ£º

ÍƼö9¿îºÜ°ôµÄÍøÒ³»æÖÆͼ±íJavaScript¿ò¼Ü½Å±¾


    ½ñÌìÒªÏò´ó¼ÒÍƼö9¿îºÜ°ôµÄ¿ÉÔÚÍøÒ³ÖлæÖÆͼ±íµÄJavaScript½Å±¾£¬ÕâЩÓÐȤµÄJS½Å±¾¿ÉÒÔ°ïÖúÄã¿ìËÙ·½±ãµÄ»æÖÆͼ±í£¨Ïß¡¢Ãæ¡¢±ý¡¢Ìõ…£©£¬ÆäÖаüÀ¨jQuery¡¢MooTools¡¢PrototypeºÍһЩÆäËüµÄJavaScript¿ò¼Ü¡£

Äú»¹¿ÉÒԲο¼ÒÔÏÂJavaScript/CSSÏà¹Ø½Ì³Ì¼°×ÊÔ´:


¡¶¾«Ñ¡30¸öÓÅÐãµÄCSS¼¼Ê ......

JavaScriptº¯Êý


http://xiayuanfeng.javaeye.com/blog/£¨Ô­ÎÄ£©
ʲôÊǺ¯Êý(Function)
function sum(a,b){  
     return a+b;  
}  
ÆäʵͨË×µÄ˵¾ÍÊÇÒ»¸öÓÐÃû³ÆµÄ´úÂë¶Î£¬·½±ãÖØÓá£
ҪעÒâµÄÊÇ£º
1.Javascript µÄº¯ÊýÓï·¨£¬ÒòΪJavascript±¾Éí¾ÍÊÇÇø·Ö´óСдµÄ£¬ËùÒÔfunction²»ÄÜд×÷Function»ò ......

Javascript¼Ì³Ð»úÖÆ£¨call¡¢apply¡¢prototype£©

JavascriptµÄ¼Ì³Ð¿ÉÒÔͨ¹ýcall¡¢apply¡¢prototypeʵÏÖ¡£
1¡¢call£ºÔÚ×ÓÀàÖУ¬Óø¸Àà.call£¨this£¬arg0£¬arg1...£©¿ÉÒԼ̳и¸Àà¡£×¢ÒâcallµÄλÖ㬾¡Á¿ÔÚ×ÓÀàµÄµÚÒ»ÐУ¨js°´Ë³ÐòÖ´ÐУ¬·ÅÔÚºóÃæ¿ÉÄܶÔ×ÓÀàµÄÆäËûÊôÐÔ¡¢·½·¨ÓÐÓ°Ïì¡£±ÈÈç×ÓÀàºÍ¸¸ÀàÓÐÏàͬÃû×ֵķ½·¨£¬ºóÃæµÄ¸²¸ÇÇ°ÃæµÄ£©¡£
<html>
<head>
<t ......

12ÖÖ²»ÒËʹÓõÄJavascriptÓï·¨


Õ⼸Ì죬ÎÒÔÚ¶Á¡¶JavascriptÓïÑÔ¾«´â¡·¡£
Õâ±¾ÊéºÜ±¡£¬100¶àÒ³£¬ÕýºÃ¼ÙÈÕÀï·­·­¡£
¸ÃÊéµÄ×÷ÕßÊÇDouglas Crockford£¬ËûÊÇÄ¿Ç°ÊÀ½çÉÏ×ͨJavascriptµÄÈËÖ®Ò»£¬Ò²ÊÇJson¸ñʽµÄ´´ÔìÕß¡£
ËûÈÏΪJavascriptÓкܶàÔãÆÉ¡£ÒòΪ1995ÄêBrendan EichÉè¼ÆÕâÖÖÓïÑÔµÄʱºò£¬Ö»ÓÃÁËÈý¸öÔ£¬ºÜ¶àÓïÑÔÌØÐÔûÓо­¹ýÉî˼ÊìÂÇ£¬¾ÍÍÆÏòÁËÊÐ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ