JavaScriptÖÐnull, undefined µÄÉîÈë̽ÌÖ
null, undefined
Ïàͬ£º
µ±Ò»¸ö±äÁ¿µÄÖµÊÇnull, undefinedʱ£¬±íʾ£ºÎÒÃÇÉùÃ÷²¢¶¨ÒåÁËÒ»¸ö±äÁ¿£¬½ö½öÊÇÕâ¸ö±äÁ¿µÄÖµÊÇnull, undefined.
±»µ÷ÓÃÕߣº
½«null, undefined×÷Ϊ²ÎÊý´«Èë"JavaScriptÄÚÖú¯Êý"ʱ£¬²»»á³öÏÖÒì³££¬ÄÚÖú¯Êý·µ»Ø£ºnull -> null, undefined->undefined
µ«typeofº¯Êý³ýÍâ¡£
µ÷ÓÃÕߣº
ÔÚnull, undefinedÉϵ÷ÓÃÊôÐÔ£¬·½·¨»á³öÏÖÒì³£¡£
²»Í¬£º
ÌØÊâµÄtypeofº¯Êý£¬ typeof null -> "object" typeof undefined -> "undefined"
Ìرð×¢Ò⣺
ÔÚJavaScriptÖУ¬Èç¹ûÒ»¸ö±äÁ¿Ã»ÓÐÉùÃ÷£¬Ò²¾ÍÊDz»´æÔڵġ£
±»µ÷ÓÃÕߣº
½«Ã»ÓÐÉùÃ÷µÄ±äÁ¿×÷Ϊ²ÎÊý´«Èë"ÈÎÒâµÄJavaScriptº¯Êý"ʱ£¬»á³öÏÖÒì³££¬µ«typeofº¯Êý³ýÍâ¡£
µ÷ÓÃÕߣº
ÔÚûÓÐÉùÃ÷µÄ±äÁ¿Éϵ÷ÓÃÊôÐÔ£¬·½·¨»á³öÏÖÒì³£¡£
ÌØÊâµÄtypeofº¯Êý£¬ ¶ÔÒ»¸öûÓÐÉùÃ÷µÄ±äÁ¿£¬ÀýÈ磺undeclared, typeof undeclared : ·µ»Ø "undefined".
Òò´Ë¶ÔÒ»¸ö±äÁ¿µ÷ÓÃtypeof ·½·¨ÊÇ×î±£Ïյġ£ÀýÈç±È½ÏÒ»¸ö±äÁ¿book, µ÷Óà book == null , book == undefined £¬
Èç¹ûbook±äÁ¿Ã»ÓÐÉùÃ÷£¬Ôò³öÏÖÒì³££¬µ«ÊÇtypeof book Ôò²»»á³öÏÖÈκÎÒì³£¡£
º¯ÊýµÄ²ÎÊý£¬ºÍ¶ÔÏóµÄÊôÐÔ£¬ÊôÓÚÒѾÉùÃ÷µÄ±äÁ¿¡£
¶ÔÓÚûÓÐÉùÃ÷µÄ±äÁ¿£¬³ýtypeofº¯ÊýÖ®Í⣬ ÆäËüµÄÈκβÙ×÷£¬¶¼»á³öÏÖÒì³£¡£
¶ÔÓÚÒѾÉùÃ÷µÄ±äÁ¿£¬Êµ¼ÊËüÒѾÊÇ´æÔÚ£¬ÆäÖµÐèÒªÇø·Önull, undefined, instance(ʵÀý)¡£
µ÷ÓÃÕߣº
ÔÚnull, undefinedÉϵ÷ÓÃÊôÐÔ£¬·½·¨»á³öÏÖÒì³£¡£
ÔÚinstanceÉϵ÷Óò»´æÔÚµÄÊôÐÔ£¬²»»á³öÏÖÒì³££¬ÒòΪ¶ÔÏóµÄÊôÐÔ¶¼ÊÇÒѾÉùÃ÷µÄ±äÁ¿£¬
µ«Êǵ÷Óò»´æÔڵķ½·¨£¬Ôò³öÏÖÒì³£¡£
Ïà¹ØÎĵµ£º
Ç°¼¸Ì죬ÔÚͼÊé¹Ý¿´ÁËÒ»±¾Êé½Ð¡¶JavaScript Dom ±à³ÌÒÕÊõ¡·´ÓÖг¢µ½ºÜ¶à֪ʶ»òÕß³ÆÆäΪ·½·¨£¬ÓÉÓÚÒ»Ö±ÔÚ棬ûÓÐʱ¼äд³öÀ´·ÖÏí¸ø´ó¼Ò£¬½ñÌìÕýºÃÓеãʱ¼äËùÒÔ¾Íд³öÀ´°É£¬Õâ±¾ÊéµÄ×÷ÕßJeremy Keith ÎÒÒÔǰûÓÐÌýµ½¹ýÕâ¸öÈË£¬´ËÊéÖоÍÒ»¶Î»°ÊÇ˵“ÎÞÂÛºÎʱµØ£¬¶¼Òª°Ñ‘ÑÐò½¥½ø’ºÍ ......
eval(str)
ÓÃÀ´´«ÈëÒ»¸ö×Ö·û´®¶¯Ì¬Ö´ÐÐÒ»¶Î½Å±¾£¬Õâ¸ö·½·¨·Ç³£ÓÐÓᣵ±Ö±½ÓÓÃeval()ʱ£¬×÷ÓÃÓòΪµ±Ç°×÷ÓÃÓò£¬ÓÐʱºòÎÒÃÇÐèÒªÈÃËüÔÚÈ«¾Ö×÷ÓÃÓò·¶Î§ÄÚÖ´ÐУ¬±ÈÈç
ajax·µ»ØµÄ½Å±¾×Ö·û´®£¬È»¶øä¯ÀÀÆ÷¶ÔevalµÄ²îÒì¿ÉÄÜʹÊÂÇé¸Õ¿ªÊ¼²¢²»ÊÇÄÇô˳Àû£¬±¾ÎÄͨ¹ýÔÚ7ÖÖä¯ÀÀÆ÷(IE, Firefox,
Chrome, Safari, Opera£©»·¾³Öвâ ......
·½·¨Ò»£º
ÓÃ;£ºÓÃÓÚ»ñµÃÔÚCSSÎļþÖÐÉùÃ÷µÄÌض¨ÑùʽÖеÄijÊôÐÔÖµ¡£È磺
<link id="system_style" type="text/css" href="global.css" rel="stylesheet"/>
<div id="myArticle" style="left:10px;top:35px;" >
ÔÚglobal.cssÖÐÉùÃ÷ÁË
#myArticle{width:400px; height:300px;}
ÕâÑùµÄÇé¿öÏ£¬Ö±½Óͨ¹ ......
×î½ü·¢ÏÖDOMDocument¶ÔÏóºÜÖØÒª,»¹ÓÐXMLHTTPÒ²ºÜÖØÒª
×¢Òâ´óСдһ¶¨²»ÄÜŪ´í.
ÊôÐÔ:
1Attributes ´æ´¢½ÚµãµÄÊôÐÔÁбí(Ö»¶Á)
2childNodes ´æ´¢½ÚµãµÄ×Ó½ÚµãÁбí(Ö»¶Á)
3dataType ·µ»Ø´Ë½ÚµãµÄÊý¾ÝÀàÐÍ
4Definition ÒÔDTD»òXMLģʽ¸ø³öµÄ½ÚµãµÄ¶¨Òå(Ö»¶Á)
5Doctype Ö¸¶¨ÎĵµÀàÐͽڵã(Ö»¶Á)
6documentE ......
×÷Õß:
YITU.org
À´Ô´:
YITU.org
ʱ¼ä:
2007-02-26 10:34:58
ÓÐʱÎÒÃÇÐèÒªÔÚ¿Í»§¶Ë»ñÈ¡Á´½Ó²ÎÊý£¬Ò»¸ö³£¼ûµÄ·½·¨Êǽ«Á´½Óµ±×ö×Ö·û´®£¬°´ÕÕÁ´½ÓµÄ¸ñʽ·Ö½â£¬È»ºó»ñÈ¡¶ÔÓ¦µÄ²ÎÊýÖµ¡£±¾Îĸø³öµÄ¾ÍÊÇÕâ¸öÁ÷³ÌµÄ¾ßÌåʵÏÖ·½·¨¡£
µ±È»£¬ ......