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

JavaScript »ñȡʼþ¶ÔÏóµÄÒ»¸ö×¢Òâµã¡¾ÎÊÌâ¡¿


JavaScript »ñȡʼþ¶ÔÏóµÄÒ»¸ö×¢Òâµã
2009-7-24 ÉÏÎç
- JS/Ajax/AS/Flex
- event
- javascript
  
ƽʱÎÒÃÇ»ñȡʼþ¶ÔÏóÒ»°ãд·¨ÈçÏ£º
function
getEvent
(
event
)

{
   
return

event

||
window
.
event
 
// IE:window.event
}
Èç¹ûûÓвÎÊý£¬Ò²¿Éд³É£¨·ÇIE £ºÊ¼þ¶ÔÏó»á×Ô¶¯´«µÝ¸ø¶ÔÓ¦µÄʼþ´¦Àíº¯Êý£¬ÇÒΪµÚÒ»¸ö²ÎÊý£©£º
function
getEvent
()

{
   
return
arguments
[
0
]

||
window
.
event

// IE:window.event
}
ÕâÑùµÄд·¨ÔÚ³ý Firefox£¨²âÊÔ°æ±¾£º3.0.12£¬ÏÂͬ£© ÍâµÄä¯ÀÀÆ÷ÉÏÔËÐж¼²»»áÓÐÎÊÌ⣬µ« Firefox
ΪʲôÀýÍâÄØ£¿ÈÃÎÒÃÇÕâÑùÒ»ÖÖÇéÐΣº
<button
id
=
"btn"

onclick
=
"
foo
()
"
>
°´Å¥
</button>
<script>
function
foo
(){
   
var
e
=
 getEvent
();
   alert
(
e
);
}
</script>
ÔËÐнá¹ûÔÚ Firefox ÖÐÊÇ undefined
£¬ÎªÊ²Ã´ÄØ£¿
ÔÚ Firefox Öе÷ÓÃÆäʵÊÇÕâÑùµÄ£¬Ïȵ÷ÓÃÖ´ÐеÄÊÇ£º
function
onclick
(
event
)

{
    foo
();
}
È»ºóµ÷ÓÃÖ´ÐеÄÊÇ£º
function
foo
(){
   
var
e
=
 getEvent
();
   alert
(
e
);
}
»á·¢ÏÖÔÚ Firefox Ï onclick
=
"foo()"
ÖÐµÄ foo
()
ÎÞ·¨×Ô¶¯´«Èëʼþ¶ÔÏó²ÎÊý£¬¶øĬÈÏ´«µÝ¸øÁËϵͳÉú³ÉµÄ
onclick º¯Êý£¬ÄDZ¾ÀýÎÒÃÇ¿ÉÒÔͨ¹ý getEvent
.
caller
.
caller
.
arguments
[
0
]
»ñµÃʼþ¶ÔÏó¡£
Òò´Ë£¬ÎÒÃÇµÄ getEvent ¿ÉÒÔÓÅ»¯³É£¨²ÎÕÕ yui_2.7.0b ÖÐµÄ event/event-debug.js ÖÐ getEvent
·½·¨£©£º
function
getEvent
(
event
)

{
   
var
ev
=

event

||
window
.
event
;
   
if

(!
ev
)

{
       
var
c
=

this
.
getEvent
.
caller
;
       
while

(
c
)

{
            ev
=
c
.
arguments
[
0
];
           
if

(
ev
&&

(
Event

==
ev
.
constructor

||

MouseEvent
 
==
ev
.


Ïà¹ØÎĵµ£º

JavaScript¶ÔframesetµÄ²Ù×÷×ܽá

1 ¿ò¼Ü±à³Ì¸ÅÊö
    Ò»¸öHtml Ò³Ãæ¿ÉÒÔÓÐÒ»¸ö»ò¶à¸ö×Ó¿ò¼Ü£¬ÕâЩ×Ó¿ò¼ÜÒÔ<iframe>À´±ê¼Ç£¬ÓÃÀ´ÏÔʾһ
¸ö¶ÀÁ¢µÄHtml Ò³Ãæ¡£ÕâÀïËù½²µÄ¿ò¼Ü±à³Ì°üÀ¨¿ò¼ÜµÄ×ÔÎÒ¿ØÖÆÒÔ¼°¿ò¼ÜÖ®¼äµÄ»¥Ïà·ÃÎÊ£¬
ÀýÈç´ÓÒ»¸ö¿ò¼ÜÖÐÒýÓÃÁíÒ»¸ö¿ò¼ÜÖеÄJavaScript±äÁ¿¡¢µ÷ÓÃÆäËû¿ò¼ÜÄڵĺ¯Êý¡¢¿ØÖÆÁíÒ»
¸ö¿ò¼ÜÖÐ±íµ¥µÄÐÐΪµ ......

JavaScriptËæ»ú±ä»»±í¸ñ±³¾°

s<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>ÎÞ±êÌâÎĵµ< ......

javascript¶¨Ê±¸ü»»±í¸ñ±³¾°

<html>
<head>
<title>changePage</title>
</head>
<body>
<table id="pic" cellpadding="0" cellspacing="0" border="1" width="200" height="100" bordercolor="red">
<tr>
<td>picture chanage!</td>
</tr>
</table>
< ......

javascript±Õ°ü ͨË×½âÊÍ

 ×î½üÔÚÍøÉϲéÔÄÁ˲»ÉÙJavascript±Õ°ü(closure)Ïà¹ØµÄ×ÊÁÏ£¬Ð´µÄ´ó¶àÊǷdz£µÄѧÊõºÍרҵ¡£¶ÔÓÚ³õѧÕßÀ´Ëµ±ð˵Àí½â±Õ°üÁË£¬¾ÍÁ¬ÎÄ×ÖÐðÊö¶¼ºÜÄÑ¿´¶®¡£×«Ð´´ËÎĵÄÄ¿µÄ¾ÍÊÇÓÃ×îͨË×µÄÎÄ×Ö½Ò¿ªJavascript±Õ°üµÄÕæʵÃæÄ¿¡£
¡¡¡¡Ò»¡¢Ê²Ã´ÊDZհü£¿
¡¡¡¡“¹Ù·½”µÄ½âÊÍÊÇ£ºËùν“±Õ°ü”£¬Ö¸µÄÊÇÒ»¸öÓµÓÐÐ ......

15 ¸ö JavaScript Web UI ¿â

¼¸ºõËùÓеĸ» Web Ó¦Óö¼»ùÓÚÒ»¸ö»ò¶à¸ö Web UI ¿â»ò¿ò¼Ü£¬ÕâЩ UI ¿âÓë¿ò¼Ü¼«´óµØ¼ò»¯ÁË¿ª·¢½ø³Ì£¬²¢´øÀ´Ò»Ö£¬¿É¿¿£¬ÒÔ¼°¸ß¶È½»»¥ÐÔµÄÓû§½çÃæ¡£±¾ÎĽéÉÜÁË 15 ¸ö·Ç³£Ç¿´óµÄ JavaScript Web UI ¿â£¬·Ç³£Êʺϸ÷ÖÖ¸÷ÖÖ¹æÄ£µÄ¸» Web Ó¦ÓõĿª·¢¡£
LivePipe
LivePipe UI »ùÓÚ Prototype Javascript ¿ò¼Ü£¬°üº¬ÁËÒ»ÕûÌ×¾­Ñϸ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ