js»ñÈ¡HTML DOM½ÚµãÔªËØ·½·¨×ܽá
ÔÚWebÓ¦ÓóÌÐòÌرðÊÇWeb2.0³ÌÐò¿ª·¢ÖУ¬¾³£Òª»ñÈ¡Ò³ÃæÖÐij¸öÔªËØ£¬È»ºó¸üиÃÔªËصÄÑùʽ¡¢ÄÚÈݵȡ£ÈçºÎ»ñÈ¡Òª¸üеÄÔªËØ£¬ÊÇÊ×ÏÈÒª½â¾öµÄÎÊÌâ¡£ÁîÈËÐÀοµÄÊÇ£¬Ê¹ÓÃJavaScript»ñÈ¡½ÚµãµÄ·½·¨ÓкܶàÖÖ£¬ÕâÀï¼òµ¥×öÒ»ÏÂ×ܽᣨÒÔÏ·½·¨ÔÚIE7ºÍFirefox2.0.0.11²âÊÔͨ¹ý£©¡£
1. ͨ¹ý¶¥²ãdocument½Úµã»ñÈ¡£º
(1)document.getElementById(elementId) £º¸Ã·½·¨Í¨¹ý½ÚµãµÄID£¬¿ÉÒÔ׼ȷ»ñµÃÐèÒªµÄÔªËØ£¬ÊDZȽϼòµ¥¿ì½ÝµÄ·½·¨¡£Èç¹ûÒ³ÃæÉϺ¬Óжà¸öÏàͬidµÄ½Úµã£¬ÄÇôֻ·µ»ØµÚÒ»¸ö½Úµã¡£
Èç½ñ£¬ÒѾ³öÏÖÁËÈçprototype¡¢MootoolsµÈ¶à¸öJavaScript¿â£¬ËüÃÇÌṩÁ˸ü¼ò±ãµÄ·½·¨£º$(id)£¬²ÎÊýÈÔÈ»ÊǽڵãµÄid¡£Õâ¸ö·½·¨¿ÉÒÔ¿´×÷ÊÇdocument.getElementById()µÄÁíÍâÒ»ÖÖд·¨£¬²»¹ý$()µÄ¹¦ÄܸüΪǿ´ó£¬¾ßÌåÓ÷¨¿ÉÒԲο¼ËüÃǸ÷×ÔµÄAPIÎĵµ¡£
(2)document.getElementsByName(elementName) £º¸Ã·½·¨ÊÇͨ¹ý½ÚµãµÄname»ñÈ¡½Úµã£¬´ÓÃû×Ö¿ÉÒÔ¿´³ö£¬Õâ¸ö·½·¨·µ»ØµÄ²»ÊÇÒ»¸ö½ÚµãÔªËØ£¬¶øÊǾßÓÐͬÑùÃû³ÆµÄ½ÚµãÊý×顣Ȼºó£¬ÎÒÃÇ¿ÉÒÔͨ¹ýÒª»ñÈ¡½ÚµãµÄij¸öÊôÐÔÀ´Ñ»·ÅжÏÊÇ·ñΪÐèÒªµÄ½Úµã¡£
ÀýÈ磺ÔÚHTMLÖÐcheckboxºÍradio¶¼ÊÇͨ¹ýÏàͬµÄnameÊôÐÔÖµ£¬À´±êʶһ¸ö×éÄÚµÄÔªËØ¡£Èç¹ûÎÒÃÇÏÖÔÚÒª»ñÈ¡±»Ñ¡ÖеÄÔªËØ£¬Ê×ÏÈ»ñÈ¡¸Ã×éÔªËØ£¬È»ºóÑ»·ÅжÏÊǽڵãµÄcheckedÊôÐÔÖµÊÇ·ñΪtrue¼´¿É¡£
(3)document.getElementsByTagName(tagName) £º¸Ã·½·¨ÊÇͨ¹ý½ÚµãµÄTag»ñÈ¡½Úµã£¬Í¬Ñù¸Ã·½·¨Ò²ÊÇ·µ»ØÒ»¸öÊý×飬ÀýÈ磺document.getElementsByTagName('A')½«»á·µ»ØÒ³ÃæÉÏËùÓг¬Á´½Ó½Úµã¡£
ÔÚ»ñÈ¡½Úµã֮ǰ£¬Ò»°ã¶¼ÊÇÖªµÀ½ÚµãµÄÀàÐ͵ģ¬ËùÒÔʹÓø÷½·¨±È½Ï¼òµ¥¡£µ«ÊÇȱµãÒ²ÊÇÏÔ¶øÒ×¼û£¬ÄǾÍÊÇ·µ»ØµÄÊý×é¿ÉÄÜÊ®·ÖÅÓ´ó£¬ÕâÑù¾Í»áÀ˷Ѻܶàʱ¼ä¡£ÄÇô£¬Õâ¸ö·½·¨ÊDz»ÊǾÍûÓÐÓô¦ÁËÄØ£¿µ±È»²»ÊÇ£¬Õâ¸ö·½·¨ºÍÉÏÃæµÄÁ½¸ö²»Í¬£¬Ëü²»ÊÇdocument½ÚµãµÄרÓз½·¨£¬»¹¿ÉÒÔÓ¦ÓÃÆäËûµÄ½Úµã£¬ÏÂÃ潫»áÌáµ½¡£
2¡¢Í¨¹ý¸¸½Úµã»ñÈ¡£º
(1)parentObj.firstChild £ºÈç¹û½ÚµãΪÒÑÖª½Úµã£¨parentObj£©µÄµÚÒ»¸ö×Ó½Úµã¾Í¿ÉÒÔʹÓÃÕâ¸ö·½·¨¡£Õâ¸öÊôÐÔÊÇ¿ÉÒԵݹéʹÓõģ¬Ò²¾ÍÊÇÖ§³Ö:
parentObj.firstChild.firstChild.firstChild...
µÄÐÎʽ£¬Èç´Ë¾Í¿ÉÒÔ»ñµÃ¸üÉî²ã´ÎµÄ½Úµã¡£
(2)parentObj.lastChild £ººÜÏÔÈ»£¬Õâ¸öÊôÐÔÊÇ»ñÈ¡ÒÑÖª½Úµã£¨parentObj£©µÄ×îºóÒ»¸ö×ӽڵ㡣ÓëfirstChildÒ»Ñù£¬ËüÒ²¿ÉÒԵݹéʹÓá£ÔÚʹÓÃÖУ¬Èç¹ûÎÒÃǰѶþÕß½áºÏÆðÀ´£¬ÄÇô½«»á´ïµ½¸ü¼ÓÁîÈËÐ˷ܵÄЧ¹û£¬¼´£ºparentObj.firstChild.lastChild.la
Ïà¹ØÎĵµ£º
metaÊÇÓÃÀ´ÔÚHTMLÎĵµÖÐÄ£ÄâHTTPÐÒéµÄÏìӦͷ±¨ÎÄ¡£meta
±êÇ©ÓÃÓÚÍøÒ³µÄ<head>Óë</head>ÖУ¬meta ±êÇ©µÄÓô¦ºÜ¶à¡£meta
µÄÊôÐÔÓÐÁ½ÖÖ£ºnameºÍhttp-equiv¡£nameÊôÐÔÖ÷ÒªÓÃÓÚÃèÊöÍøÒ³£¬¶ÔÓ¦ÓÚcontent£¨ÍøÒ³ÄÚÈÝ£©£¬ÒÔ±ãÓÚËÑË÷ÒýÇæ»úÆ÷È˲éÕÒ¡¢·ÖÀࣨĿ
Ç°¼¸ºõËùÓеÄËÑË÷ÒýÇ涼ʹÓÃÍøÉÏ»úÆ÷ÈË×Ô¶¯²éÕ ......
´Ë´¦Ç¶ÈëµÄflashÀïÃæµÄͼƬÊÇ¿ÉÒÔËæʱ·¢Éú¸Ä±äµÄͼƬ£¨¶¯Ì¬Í¼Æ¬£©
×¢ÒâÀ¶É«×ÖÌåµÄµØ·½£¬ÕâЩµØ·½¶¼ÒªÍ³Ò»
<script language="javascript">AC_FL_RunContent = 0;</script>
<script src="${ctx}/ui/Login/AC_RunActiveContent.js"
language="javascript"></script& ......
<input type="text" value="" maxlength="18"
name="goods.goodsName" value="${goods.goodsName}"
style="width: 99%;" id="goodsName">
value ÊôÐÔ Öظ´ £¬ µ¼Ö嵀 input ǰ̨ҳÃæ Öµ Ϊ ""
ÒÔµÚÒ»¸öÊôÐÔµÄÖµÎª× ......
AjaxÏÖÔÚÒѾÊÇÏ൱Á÷Ðеļ¼ÊõÁË£¬Ajax²»½öÊÇÏë·þÎñÆ÷¶Ë·¢ËÍÏûÏ¢£¬¸üÖØÒªµÄÊÇÎÞˢеÄÖØÔØÒ³Ãæ¡£
Èç¹ûÒ³Ãæµ¥´¿µÄʹÓÃjsÀ´´´½¨£¬ÒªÐ´´óÁ¿µÄ´úÂ룬¶øÇÒ²»Ö±¹Û¡£
ÔÚasp.netÖУ¬ÆäʵÎÒÃÇ¿ÉÒÔ´´½¨Óû§×Ô¶¨Òå¿Ø¼þ£¬Í¨¹ýAjaxÇëÇó·µ»ØÓû§×Ô¶¨Òå¿Ø¼þHTML´úÂë¡£
public static string RangerUsControl(string controlName) ......
×î³£ÓõÄ×Ö·ûʵÌå
ÏÔʾ½á¹ûÃèÊöʵÌåÃû³ÆʵÌå±àºÅ
¿Õ¸ñ
 
<
СÓÚºÅ
<
<
>
´óÓÚºÅ
>
>
&
ºÍºÅ
&
&
"
ÒýºÅ
"
"
'
ƲºÅ
' (IE²»Ö§³Ö)
'
ÆäËûһЩ³£ÓõÄ×Ö·ûʵÌå
ÏÔʾ ......