javascript CDATAµÄÒâÒå
CDATA ÄÚ²¿µÄËùÓж«Î÷¶¼»á±»½âÎöÆ÷ºöÂÔ¡£
¼ÙÈçÎı¾Öаüº¬ÁË´óÁ¿µÄ "<" ºÍ "&" ×Ö·û - ¾ÍÏñ±à³Ì´úÂëÖо³£³öÏÖµÄÇé¿öÒ»Ñù - ÄÇôÕâ¸ö XML ÔªËؾͿÉÒÔ±»¶¨ÒåΪһ¸ö CDATA ²¿·Ö¡£
CDATA Çø¶Î¿ªÊ¼ÓÚ "<![CDATA["£¬½áÊøÓÚ "]]>"£º
<script type="text/javascript">
<![CDATA[
function compare(a,b)
{
if (a < b)
{alert("aСÓÚb");}
else if (a>b)
{alert("a´óÓÚb");}
else
{alert("aµÈÓÚb");}
}
]]>
</script>
ÔÚÉÏÃæµÄÀý×ÓÖУ¬ÔÚ CDATA Çø¶ÎÖеÄËùÓж«Î÷¶¼»á±»½âÎöÆ÷ºöÂÔ¡£
¹ØÓÚ CDATA Çø¶ÎµÄ×¢ÊÍ:
CDATA Çø¶Î²»ÄÜ°üº¬×Ö·û´® "]]>"£¬ËùÒÔ£¬CDATA Çø¶ÎµÄǶÌ×ÊDz»±»ÔÊÐíµÄ¡£
ͬʱҲÐèҪȷ±£ÔÚ "]]>" ×Ö·û´®ÖÐûÓпոñ»òÕÛÐС£
ΪʲôҪʹÓÃCDATA:
XHTMLµÄµÚ¶þ¸ö¸Ä±äÊÇʹÓÃCDATA¶Î¡£XMLÖеÄCDATA¶ÎÓÃÓÚÉùÃ÷²»Ó¦±»½âÎöΪ±êÇ©µÄÎı¾£¨XHTMLÒ²ÊÇÈç´Ë£©£¬ÕâÑù¾Í¿ÉÒÔʹÓÃÌØÊâ×Ö·û£¬ÈçСÓÚ£¨<£©¡¢´óÓÚ£¨>£©¡¢ºÍºÅ£¨&£©ºÍË«ÒýºÅ£¨"£©£¬¶ø²»±ØʹÓÃËüÃǵÄ×Ö·ûʵÌå¡£¿¼ÂÇÏÂÃæµÄ´úÂ룺
<script type="text/javascript">
function compare(a,b)
{
if (a < b)
{alert("aСÓÚb");}
else if (a>b)
{alert("a´óÓÚb");}
else
{alert("aµÈÓÚb");}
}
</script>
Õâ¸öº¯ÊýÏ൱¼òµ¥£¬Ëü±È½ÏÊý×ÖaºÍb£¬È»ºóÏÔʾÏûϢ˵Ã÷ËüÃǵĹØϵ¡£µ«ÊÇ£¬ÔÚXHTMLÖУ¬Õâ¶Î´úÂëÊÇÎÞЧµÄ£¬ÒòΪËüʹÓÃÁËÈý¸öÌØÊâ·ûºÅ£¬¼´Ð¡ÓÚ¡¢´óÓÚºÍË«ÒýºÅ¡£ÒªÐÞÕýÕâ¸öÎÊÌ⣬±ØÐë·Ö±ðÓÃÕâÈý¸ö×Ö·ûµÄXMLʵÌå<¡¢>ºÍ"Ìæ»»ËüÃÇ£º
<script type="text/javascript">
function compare(a,b)
{
if (a <b)
{alert("aСÓÚb");}
else if (a>b)
{alert("a´óÓÚb");}
else
{alert("aµÈÓÚb");}
}
</script>
Õâ¶Î´úÂë´æÔÚÁ½¸öÎÊÌâ¡£Ê×ÏÈ£¬¿ª·¢Õß²»Ï°¹ßÓÃXMLʵÌå±àд´úÂë¡£Õâʹ´úÂëºÜÄѶÁ¶®¡£Æä´Î£¬ÔÚJavaScriptÖУ¬ÕâÖÖ´úÂëʵ¼ÊÉϽ«ÊÓΪÓÐÓï·¨´í£¬ÒòΪ½âÊͳÌÐò²»ÖªµÀXMLʵÌåµÄÒâ˼¡£ÓÃCDATA¶Î¼´¿ÉÒÔÒÔ³£¹æÐÎʽ£¨¼´Ò׶ÁµÄÓï·¨£©±àдJavaScript´úÂë¡£Õýʽ¼ÓÈëCDATA¶ÎµÄ·½·¨ÈçÏ£º
<script type="text/javascript">
Ïà¹ØÎĵµ£º
AS("#...").keypress(function(event) {
if (navigator.userAgent.toLowerCase().indexOf("mozilla") >= 0) {
var $key = event.charCode ;
} else {
var $key = event. ......
È¥³ý×Ö·û´®×óÓÒÁ½¶ËµÄ¿Õ¸ñ£¬ÔÚvbscriptÀïÃæ¿ÉÒÔÇáËɵØʹÓà trim¡¢ltrim »ò rtrim£¬µ«ÔÚjsÖÐȴûÓÐÕâ3¸öÄÚÖ÷½·¨£¬ÐèÒªÊÖ¹¤±àд¡£ÏÂÃæµÄʵÏÖ·½·¨ÊÇÓõ½ÁËÕýÔò±í´ïʽ£¬Ð§Âʲ»´í£¬²¢°ÑÕâÈý¸ö·½·¨¼ÓÈëString¶ÔÏóµÄÄÚÖ÷½·¨ÖÐÈ¥¡£
<input type="text" name="mytxt" value=" 12345678 &nbs ......
½ñÌì¿´µ½¡¶AJAX¿ª·¢¼òÂÔ¡·ÖÐËùÓеÄ<A href>¶¼Óõ½ÁËjavascript:void(0)
½ñÌì¿´ÁËÒ»ÏÂÔÀ´Õâ¸ö±í´ïʽµÄ×÷ÓþÍÊÇÈõ±Ç°Õâ¸ö³¬Á´½Ó³ÉΪһ¸öËÀÁ´½Ó£¬¾ÍÊÇʲô¶¼²»×÷¡£
ÒÔÏÂÕª×Ô£º
http://blog.csdn.net/mouyong/archive/2007/01/24/1491761.aspx
±ðÈËЩµÄJavaScript½Å±¾¿ÉÒÔ¿´µ½ÕâÑùµÄ´úÂ룺
<a href="javascript ......
ÒÔÇ°ÒòΪ½Ó´¥µÄÏîÄ¿£¬Óõ½javascriptµÄµØ·½£¬±¾È˶ÔjavascriptÕâ¸ö¶«Î÷ÈÏʶ²»¹»£¬ÉõÖÁÒÔΪÊÇǰ̨³ÌÐòÔ±µÄ¹¤×÷¡£×î½ü×öµÄÏîÄ¿ÀïÃæÓõ½Á˺ܶàÕâÖֽű¾ÓïÑÔ£¬²Å·¢ÏÖÕâ¸öС¶«¶«ÊµÔÚÊǺܿɰ®£¬ËäÈ»ºÜÌÔÆø£¨²»ÊǺÜÃæÏò¶ÔÏñ£¬²»ÊǺܺõ÷ÊÔ£©£¬µ«ÊÇÖ»ÒªÊÇ×öweb¿ª·¢µÄ£¬¶¼ÄÑÃâÒª½Ó´¥µ½Ëû£¬°ÑÕ⸠......