javascript eventʼþ½âÎö1 only handbook
event.srcElement Óëevent.target
Javascript event.srcElement
¸Ð¾õÕâ¸öͦºÃ£¬¿ÉÒÔ²¶»ñµ±Ç°Ê¼þ×÷ÓõĶÔÏó£¬Èçevent.srcElement.tagName¿ÉÒÔ²¶»ñ»î¶¯±ê¼ÇÃû³Æ¡£
×¢Òâ»ñÈ¡µÄ±ê¼Ç¶¼ÒÔ´óд±íʾ£¬Èç"TD","TR","A"µÈ¡£ËùÒÔ°Ñ¿´¹ýµÄһЩ³ÏÂÀ´£¬²»¼ÇµÃµÄʱºòÔÙÀ´¿´¿´¡£
<script type="text/javascript">
function tdclick(){
if(event.srcElement.tagName.toLowerCase()=='td')
alert("ÐУº"+(event.srcElement.parentNode.rowIndex+1)+"ÁУº"+(event.srcElement.cellIndex+1));
}
</script>
event.srcElement´Ó×ÖÃæÉÏ¿ÉÒÔ¿´³öÀ´ÓÐÒÔϹؼü×Ö£ºÊ¼þ,Ô´ ËûµÄÒâ˼¾ÍÊÇ£ºµ±Ç°Ê¼þµÄÔ´£¬
ÎÒÃÇ¿ÉÒÔµ÷ÓÃËûµÄ¸÷ÖÖÊôÐÔ ¾ÍÏñ:document.getElementById("")ÕâÑùµÄ¹¦ÄÜ£¬
¾³£ÓÐÈËÎÊ firefox Ï嵀 event.srcElement ÔõôÓã¬ÔÚ´ËÏêϸ˵Ã÷£º
IEÏÂ,event¶ÔÏóÓÐsrcElementÊôÐÔ,µ«ÊÇûÓÐtargetÊôÐÔ;FirefoxÏÂ,event¶ÔÏóÓÐtargetÊôÐÔ,µ«ÊÇûÓÐsrcElementÊôÐÔ.µ«ËûÃǵÄ×÷ÓÃÊÇÏ൱µÄ£¬¼´£º
firefox Ï嵀 event.target = IE Ï嵀 event.srcElement
½â¾ö·½·¨:ʹÓÃobj(obj = event.srcElement ? event.srcElement : event.target;)À´´úÌæIEϵÄevent.srcElement»òÕßFirefoxϵÄevent.target.
ת×Ô£ºhttp://www.cnblogs.com/Robin-wu/archive/2008/07/25/1251453.html
Ïà¹ØÎĵµ£º
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µÄä¯ÀÀ ......
µÚËļ¯
--------------------------------------------------------------------------------
ÕâÕÂÎÒ½«¸æËßÄúÈçºÎÔÚ״̬ÁÐ (statusbar) (Ò²¾ÍÊÇÄúä¯ÀÀÆ÷×îÏ·½ÏÔʾ URLs µÄÄÇÒ»ÐÐ) ÏÔʾÎÄ×Ö£¬²¢ÇÒ½«½ÌÄú 'ÅÜÂíµÆ' (ÒÔϼò³Æ scroller ) µÄ¹¤×÷ÔÀí¡£ËäÈ»ÒÔ
JavaScript Íê³ÉµÄ scroller ĿǰÈÔÓÐЩÎÊÌâ (ÉÔáá»áÌáµ½ÎÊÌâÔ ......
constructorÊôÐÔʼÖÕÖ¸Ïò´´½¨µ±Ç°¶ÔÏóµÄ¹¹Ô캯Êý¡£±ÈÈçÏÂÃæÀý×Ó£º
// µÈ¼ÛÓÚ var foo = new Array(1, 56, 34, 12);
var arr = [
1
,
56
,
34
,
12
];
console.log(arr.constructor === Array); ......
ÄãÖªµÀÊÀ½çÉÏÓжàÉÙÖÖä¯ÀÀÆ÷Â𣿳ýÁËÎÒÃÇÊìÖªµÄIE, Firefox, Opera, SafariËÄ´óä¯ÀÀÆ÷Ö®Í⣬ÊÀ½çÉÏ»¹Óнü°ÙÖÖä¯ÀÀÆ÷¡£
¼¸Ììǰ£¬ä¯ÀÀÆ÷¼Ò×åÓиյ®ÉúÁËһλСÍõ×Ó£¬¾ÍÊÇGoogleÍÆ³öµÄChromeä¯ÀÀÆ÷¡£ÓÉÓÚChrome³öÉúÃûÃÅ£¬¾¡¹ÜËû»¹ÊǸöС¼Ò»ï£¬Ã»ÓÐÈ˸ÒС¿´Ëû¡£ÒÔºó£¬ÔÛÃdz£Ëµä¯ÀÀÆ÷µÄ&ld ......
/*
* ÓÃÀ´±éÀúÖ¸¶¨¶ÔÏóËùÓеÄÊôÐÔÃû³ÆºÍÖµ
* obj ÐèÒª±éÀúµÄ¶ÔÏó
* author: Jet Mah
* website: http://www.javatang.com/archives/2006/09/13/442864.html
*/
function allPrpos(obj) {
// ÓÃÀ´±£´æËùÓеÄÊôÐÔÃû³ÆºÍÖµ
var props = "";
&nbs ......