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

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>


Ïà¹ØÎĵµ£º

javascript: The Document Object Model(DOM)

DOM
½ÚµãÀàÐ͵Ä12¸ö³£Á¿:
Node.ELEMENT_NODE
Node.ATTRIBUTE_NODE
Node.TEXT_NODE
Node.CDATA_SECTION_NODE
Node.ENTITY_REFERENCE_NODE
Node.ENTITY_NODE
Node.PROCESSING_INSTRUCTION_NODE
Node.COMMENT_NODE
Node.DOCUMENT_NODE
Node.DOCUMENT_TYPE_NODE
Node.DOCUMENT_FRAGMENT_NODE
Node.NOTATION_NODE ......

Javascript ÀàºÍÃüÃû¿Õ¼äµÄ¶¨Òå

//1.Àà
function Test(id)
{
     this.id=id;
     this.method=function()
         {
            //´úÂë
         };
}
......

Javascript ˢпò¼Ü¼°Ò³ÃæµÄ·½·¨×ܼ¯

ÏÈÀ´¿´Ò»¸ö¼òµ¥µÄÀý×Ó£º
ÏÂÃæÒÔÈý¸öÒ³Ãæ·Ö±ðÃüÃûΪframe.html¡¢top.html¡¢bottom.htmlΪÀýÀ´¾ßÌå˵Ã÷ÈçºÎ×ö¡£
Java´úÂë
frame.html ÓÉÉÏ(top.html)ÏÂ(bottom.html)Á½¸öÒ³Ãæ×é³É£¬´úÂëÈçÏ£º   
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> ......

·ÅÒ»¸öjavascriptÓÒ¼ü²Ëµ¥µÄ´úÂë

×¢²áºÜ³¤Ê±¼äºÅÁË£¬¸Õ¿ªÍ¨²©¿Í£¬ÄóöÒ»¸ö×Ô¼ºÐ´µÄ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: ......

javascript±äÁ¿×÷ÓÃÓò

±äÁ¿µÄ×÷ÓÃÓòÖ¸µÄÊDZäÁ¿µÄ¿É¼ûÐÔ£¬¶øÉúÃüÖÜÆÚÔò£¨´æ»îÆÚ£©ÔòÊÇ´ÓÁíÒ»¸ö½Ç¶È¿¼²ì±äÁ¿¡£ jsÖбäÁ¿µÄ×÷ÓÃÓò·ÖΪȫ¾Ö±äÁ¿ºÍ¾Ö²¿±äÁ¿£¬º¯ÊýÄÚ¶¨ÒåµÄ³ÆΪ¾Ö²¿±äÁ¿£¬º¯ÊýÍâµÄ³ÆΪȫ¾Ö±äÁ¿¡££¨¡°º¯ÊýÍâµÄ³ÆΪȫ¾Ö±äÁ¿¡±ÊÇÏà¶ÔµÄ£¬Áí´Ë´¦ÌÖÂÛµÄÇ°ÌáÊÇÓÃvarÏÔʽÉùÃ÷µÄ±äÁ¿£¬º¯ÊýÄÚ²»ÓÃvar¶¨ÒåµÄ±äÁ¿Ä¬ÈÏÊÇÈ«¾Ö±äÁ¿£¬µ±È»ºöÂÔvarÉùÃ÷± ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ