JavaScriptÖÐWindow.eventÏê½â
event´ú±íʼþµÄ״̬£¬ÀýÈç´¥·¢event¶ÔÏóµÄÔªËØ¡¢Êó±êµÄλÖü°×´Ì¬¡¢°´ÏµļüµÈµÈ¡£
event¶ÔÏóÖ»ÔÚʼþ·¢ÉúµÄ¹ý³ÌÖвÅÓÐЧ¡£
eventµÄijЩÊôÐÔÖ»¶ÔÌض¨µÄʼþÓÐÒâÒå¡£±ÈÈ磬fromElement ºÍ toElement ÊôÐÔÖ»¶Ô onmouseover ºÍ onmouseout ʼþÓÐÒâÒå¡£
Àý×Ó
ÏÂÃæµÄÀý×Ó¼ì²éÊó±êÊÇ·ñÔÚÁ´½ÓÉϵ¥»÷£¬²¢ÇÒ£¬Èç¹ûshift¼ü±»°´Ï£¬¾ÍÈ¡ÏûÁ´½ÓµÄÌøת¡£
<HTML>
<HEAD><TITLE>Cancels Links</TITLE>
<SCRIPT LANGUAGE="JScript">
function cancelLink() {
if (window.event.srcElement.tagName == "A" && window.event.shiftKey)
window.event.returnValue = false;
}
</SCRIPT>
<BODY onclick="cancelLink()">
ÏÂÃæµÄÀý×ÓÔÚ״̬À¸ÉÏÏÔʾÊó±êµÄµ±Ç°Î»Öá£
<BODY onmousemove="window.status = 'X=' + window.event.x + ' Y=' + window.event.y">
ÊôÐÔ£º
altKey, button, cancelBubble, clientX, clientY, ctrlKey, fromElement, keyCode, offsetX, offsetY, propertyName, returnValue, screenX, screenY, shiftKey, srcElement, srcFilter, toElement, type, x, y
--------------------------------------------------------------------------------
1.altKey
ÃèÊö£º
¼ì²éalt¼üµÄ״̬¡£
Óï·¨£º
event.altKey
¿ÉÄܵÄÖµ£º
µ±alt¼ü°´ÏÂʱ£¬ÖµÎª TRUE £¬·ñÔòΪ FALSE ¡£Ö»¶Á¡£
2.button
ÃèÊö£º
¼ì²é°´ÏµÄÊó±ê¼ü¡£
Óï·¨£º
event.button
¿ÉÄܵÄÖµ£º
0 û°´¼ü
1 °´×ó¼ü
2 °´ÓÒ¼ü
3 °´×óÓÒ¼ü
4 °´Öмä¼ü
5 °´×ó¼üºÍÖмä¼ü
6 °´ÓÒ¼üºÍÖмä¼ü
7 °´ËùÓеļü
Õâ¸öÊôÐÔ½öÓÃÓÚonmousedown, onmouseup, ºÍ onmousemove ʼþ¡£¶ÔÆäËûʼþ£¬²»¹ÜÊó±ê״̬ÈçºÎ£¬¶¼·µ»Ø 0£¨±ÈÈçonclick£©¡£
3.cancelBubble
ÃèÊö£º
¼ì²âÊÇ·ñ½ÓÊÜÉϲãÔªËصÄʼþµÄ¿ØÖÆ¡£
Óï·¨£º
event.cancelBubble[ = cancelBubble]
¿ÉÄܵÄÖµ£º
ÕâÊÇÒ»¸ö¿É¶ÁдµÄ²¼¶ûÖµ:
TRUE ²»±»ÉϲãÔËصÄʼþ¿ØÖÆ¡£
FALSE ÔÊÐí±»ÉϲãÔªËصÄʼþ¿ØÖÆ¡£ÕâÊÇĬÈÏÖµ¡£
Àý×Ó£º
ÏÂÃæµÄ´úÂëƬ¶ÏÑÝʾÁ˵±ÔÚͼƬÉϵã»÷£¨onclick£©Ê±£¬Èç¹ûͬʱshift¼üÒ²±»°´Ï£¬¾ÍÈ¡ÏûÉϲãÔªËØ£¨body£©ÉϵÄʼþonclickËùÒý·¢µÄshowSrc()º¯Êý¡£
<SCRIPT LANGUAGE="JScript">
function checkCancel() {
if (window.event.shiftKey)
window.event.cancelBubble = true;
}
function showSrc() {
if (window.event.srcEl
Ïà¹ØÎĵµ£º
Google ÅÅÃûÖÐµÄ 10 ¸ö×îÖøÃûµÄ JavaScript ¿â ÊÕ²Ø
JavaScript ÊÇ Web ¿ª·¢ÓëÉè¼ÆÖв»¿É»òȱµÄ¶«Î÷£¬²»¹ÜÊÇÒ»¸ö¼òµ¥µÄÍøÒ³»¹ÊÇÒ»¸öרҵµÄÕ¾µã£¬Ò²²»¹ÜÄãÊǸßÊÖ»¹ÊDzËÄñ£¬Èç½ñ JavaScript ¿âÔ½À´Ô½Ç¿´ó£¬¿ÉÒÔʤÈÎÐí¶à¸´ÔӵŤ×÷£¬È»¶øͬʱ£¬ÈËÃÇÔÚÖÚ¶à JavaScript ¿âÃæÇ°ÓÖ¾õµÃÎÞËùÊÊ´Ó£¬±¾ÎÄ£¬ÎÒÃǽ«Ê¹Óà G ......
ÆäËüÃæÏò¶ÔÏóµÄÓïÑÔÈçJAVAµÄÒ»¸ö³£¼ûÌØÐÔÊÇ£¬¸ù¾Ý´«ÈëµÄ²»Í¬ÊýÁ¿»òÀàÐ͵ģ¬Í¨¹ýÖØÔØ(overload) À´·¢»Ó²»Í¬µÄ¹¦Ó᣾¡¹ÜÕâ¸öÌØÐÔÔÚJavaScriptÖв¢Ã»ÓÐÖ±½ÓÖ§³Ö£¬Ò²Óкܶà°ì·¨Äܹ»ÊµÏÖ¡£
º¯ÊýÖØÔØ£¨function overloading£©±ØÐëÒÀÀµÁ½¼þÊÂÇ飺Åжϴ«Èë²ÎÊýµÄÊýÁ¿µÄÄÜÁ¦ºÍÅжϴ«Èë²ÎÊýÀàÐ͵ÄÄÜÁ¦¡£
JavaScript掅 ......
×î½ü·¢ÏÖDOMDocument¶ÔÏóºÜÖØÒª,»¹ÓÐXMLHTTPÒ²ºÜÖØÒª
×¢Òâ´óСдһ¶¨²»ÄÜŪ´í.
ÊôÐÔ:
1Attributes ´æ´¢½ÚµãµÄÊôÐÔÁбí(Ö»¶Á)
2childNodes ´æ´¢½ÚµãµÄ×Ó½ÚµãÁбí(Ö»¶Á)
3dataType ·µ»Ø´Ë½ÚµãµÄÊý¾ÝÀàÐÍ
4Definition ÒÔDTD»òXMLģʽ¸ø³öµÄ½ÚµãµÄ¶¨Òå(Ö»¶Á)
5Doctype Ö¸¶¨ÎĵµÀàÐͽڵã(Ö»¶Á)
6documentE ......
ÔÚ±àд¹¹Ô캯Êýʱ£¬¿ÉÒÔʹÓÃÔÐͶÔÏó£¨Ëü±¾ÉíÊÇËùÓй¹Ô캯ÊýµÄÒ»¸öÊôÐÔ£©µÄÊôÐÔÀ´´´½¨¼Ì³ÐÊôÐԺ͹²Ïí·½·¨¡£ÔÐÍÊôÐԺͷ½·¨½«°´ÒýÓø´ÖƸøÀàÖеÄÿ¸ö¶ÔÏó£¬Òò´ËËüÃǶ¼¾ßÓÐÏàͬµÄÖµ¡£¿ÉÒÔÔÚÒ»¸ö¶ÔÏóÖиü¸ÄÔÐÍÊôÐÔµÄÖµ£¬ÐµÄÖµ½«¸²¸ÇĬÈÏÖµ£¬µ«½öÔÚ¸ÃʵÀýÖÐÓÐЧ¡£ÊôÓÚÕâ¸öÀàµÄÆäËû¶ÔÏó²»Êܴ˸ü¸ÄµÄÓ°Ïì¡£ÏÂÃæ¸ø³öÁËʹÓÃ×Ô¶¨Òå ......
null, undefined
Ïàͬ£º
µ±Ò»¸ö±äÁ¿µÄÖµÊÇnull, undefinedʱ£¬±íʾ£ºÎÒÃÇÉùÃ÷²¢¶¨ÒåÁËÒ»¸ö±äÁ¿£¬½ö½öÊÇÕâ¸ö±äÁ¿µÄÖµÊÇnull, undefined.
±»µ÷ÓÃÕߣº
½«null, undefined×÷Ϊ²ÎÊý´«Èë"JavaScriptÄÚÖú¯Êý"ʱ£¬²»»á³öÏÖÒì³££¬ÄÚÖú¯Êý·µ»Ø£ºnull -> null, undefined->undefined
µ«typeofº¯Êý³ýÍâ¡£
µ÷ ......