javascriptÖеÄsrcelement
srcElement ÊÇDomʼþÖеÄʼþ×î³õÖ¸Åɵ½µÄÔªËØ¡£
±ÈÈçÓÐÒ»¸ödiv£¬ÀïÃæÓÐÒ»¸ö°´Å¥¡£ÄãÏìÓ¦divµÄonclickʼþ£¬µ«Êµ¼ÊÉÏ£¬Äãµ¥»÷µÄÖ»ÊÇËüÄÚ²¿µÄ°´Å¥£¬ÄÇô£¬srcElementÖ¸ÏòµÄ£¬¾ÍÊÇÄǸö°´Å¥¡£
srcElementÖ»ÔÚIEÖÐÓÐЧ¡£
ÔÚOperaϵÁÐä¯ÀÀÆ÷ÖжÔÓ¦µÄÊôÐÔÊÇtarget
¸øÄãÒ»¸öIEÏÂʹÓõÄÀý×Ó¡£
<!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>
<title>ÎÞ±êÌâÒ³</title>
<script type="text/javascript">
function onLoad()
{
document.getElementById( "myDiv" ).attachEvent( "onclick", on_myDivClick );
}
function onUnLoad()
{
document.getElementById( "myDiv" ).detachEvent( "onclick", on_myDivClick );
}
function on_myDivClick( e )
{
if( !e ) e = window.event;
alert( "event: " + e.type + ", fromElement = " + e.srcElement.id );
}
</script>
</head>
<body onload="onLoad()" onunload="onUnLoad()">
<div id="myDiv">
<input type="button" id="btn1" value="button1" />
<input type="button" id="btn2" value="button2" />
</div>
</body>
</html>
Ïà¹ØÎĵµ£º
±¾ÎĵÄÁ½¸öÄ¿µÄ£º
£¨1£©½éÉÜjavascriptÖеÄevalº¯ÊýµÄÓ÷¨
£¨2£©ÈçºÎÔÚº¯ÊýÄÚÖ´ÐÐÈ«¾Ö´úÂë
►ÏÈÀ´ËµevalµÄÓ÷¨£¬ÄÚÈݱȽϼòµ¥£¬ÊìϤµÄ¿ÉÒÔÌø¹ý¡£
evalº¯Êý½ÓÊÕÒ»¸ö²ÎÊýs£¬Èç¹ûs²»ÊÇ×Ö·û´®£¬ÔòÖ±½Ó·µ»Øs¡£·ñÔòÖ´ÐÐsÓï¾ä¡£Èç¹ûsÓï¾äÖ´Ðнá¹ûÊÇÒ»¸öÖµ£¬Ôò·µ»Ø´ËÖµ£¬·ñÔò·µ»Øundefined¡£
ÐèÒªÌرð×¢ÒâµÄÊǶÔÏóÉùÃ÷Óï· ......
window.onbeforeunload = function (evt) {
var message = 'Are you sure you want to leave?';
if (typeof evt == 'undefined') {
evt = window.event;
}
if (evt) {
evt.returnValue = message;
}
return message;
}
onbeforeunload ʼþ²Î¿¼µØÖ·
http://msdn.microsoft.com/en-us/ ......
×¢²áºÜ³¤Ê±¼äºÅÁË£¬¸Õ¿ªÍ¨²©¿Í£¬ÄóöÒ»¸ö×Ô¼ºÐ´µÄjavascriptÓÒ¼ü²Ëµ¥£¬¼æÈÝIE£¬firefoxä¯ÀÀÆ÷
ÕâÊÇcss´úÂë
body{
font-size:12px;
}
.contextMenu{
filter:alpha(opacity=80);
opacity:0.8;
border:1px #0033FF solid;
background-color:#0099CC;
cursor:pointer;
width:120px;
position:absolute;
top: ......
ÒÔÏ·ֱðÊÇÓõݹéºÍÁ½ÖÖÑ»·¶Ôì³²¨ÄÇÆõÊýÁеļòµ¥ÊµÏÖ¡£(½á¹û½ö¹©²Î¿¼)
µÝ¹éµÄģʽ£º
function Fibonacci(num){
if(num <= 2){
return 1;
}else{
return Fibonacci(num - 1) + Fibonacci(num - 2)
}
}
var counter1 = new Counter();
Fibonacci(30);
counter1.show()
//Firefo ......
<!--
/* Font Definitions */
@font-face
{font-family:ËÎÌå;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"\@ËÎÌå" ......