JavaScriptÖеÄdocument.cookieµÄʹÓÃ
ÎÒÃÇÒѾ֪µÀ£¬ÔÚ document ¶ÔÏóÖÐÓÐÒ»¸ö cookie ÊôÐÔ¡£µ«ÊÇ Cookie ÓÖÊÇʲô£¿“ijЩ Web Õ¾µãÔÚÄúµÄÓ²ÅÌÉÏÓúÜСµÄÎı¾Îļþ´æ´¢ÁËһЩÐÅÏ¢£¬ÕâЩÎļþ¾Í³ÆΪ Cookie¡£”—— MSIE °ïÖú¡£Ò»°ãÀ´Ëµ£¬Cookies ÊÇ CGI »òÀàËÆ£¬±È HTML ¸ß¼¶µÄÎļþ¡¢³ÌÐòµÈ´´½¨µÄ£¬µ«ÊÇ javascript Ò²ÌṩÁË¶Ô Cookies µÄºÜÈ«ÃæµÄ·ÃÎÊȨÀû¡£
¡¡¡¡ÎÒÃÇÏÈҪѧһѧ Cookie µÄ»ù±¾ÖªÊ¶¡£
¡¡¡¡Ã¿¸ö Cookie ¶¼ÊÇÕâÑùµÄ£º<cookieÃû>=<Öµ>
¡¡¡¡<cookieÃû>µÄÏÞÖÆÓë javascript µÄÃüÃûÏÞÖÆ´óͬСÒ죬ÉÙÁË“²»ÄÜÓà javascript ¹Ø¼ü×Ö”£¬¶àÁË“Ö»ÄÜÓÿÉÒÔÓÃÔÚ URL ±àÂëÖеÄ×Ö·û”¡£ºóÕ߱ȽÏÄѶ®£¬µ«ÊÇÖ»ÒªÄãÖ»ÓÃ×ÖĸºÍÊý×ÖÃüÃû£¬¾ÍÍêȫûÓÐÎÊÌâÁË¡£<Öµ>µÄÒªÇóÒ²ÊÇ“Ö»ÄÜÓÿÉÒÔÓÃÔÚ URL ±àÂëÖеÄ×Ö·û”¡£
¡¡¡¡Ã¿¸ö Cookie ¶¼ÓÐʧЧÈÕÆÚ£¬Ò»µ©µçÄÔµÄʱÖÓ¹ýÁËʧЧÈÕÆÚ£¬Õâ¸ö Cookie ¾Í»á±»É¾µô¡£ÎÒÃDz»ÄÜÖ±½ÓɾµôÒ»¸ö Cookie£¬µ«ÊÇ¿ÉÒÔÓÃÉ趨ʧЧÈÕÆÚÔçÓÚÏÖÔÚʱ¿ÌµÄ·½·¨À´¼ä½ÓɾµôËü¡£
¡¡¡¡Ã¿¸öÍøÒ³£¬»òÕß˵ÿ¸öÕ¾µã£¬¶¼ÓÐËü×Ô¼ºµÄ Cookies£¬ÕâЩ Cookies Ö»ÄÜÓÉÕâ¸öÕ¾µãϵÄÍøÒ³À´·ÃÎÊ£¬À´×ÔÆäËûÕ¾µã»òͬһվµãÏÂδ¾ÊÚȨµÄÇøÓòµÄÍøÒ³£¬ÊDz»ÄÜ·ÃÎʵġ£Ã¿Ò»“×é”Cookies Óй涨µÄ×Ü´óС£¨´óÔ¼ 2KB ÿ“×锣©£¬Ò»³¬¹ý×î´ó×Ü´óС£¬Ôò×îÔçʧЧµÄ Cookie Ïȱ»É¾³ý£¬À´ÈÃÐ嵀 Cookie“°²¼Ò”¡£
¡¡¡¡ÏÖÔÚÎÒÃÇÀ´Ñ§Ï°Ê¹Óà documents.cookie ÊôÐÔ¡£
¡¡¡¡Èç¹ûÖ±½ÓʹÓà documents.cookie ÊôÐÔ£¬»òÕß˵£¬ÓÃijÖÖ·½·¨£¬ÀýÈç¸ø±äÁ¿¸³Öµ£¬À´»ñµÃ documents.cookie µÄÖµ£¬ÎÒÃǾͿÉÒÔÖªµÀÔÚÏÖÔÚµÄÎĵµÖÐÓжàÉÙ¸ö Cookies£¬Ã¿¸ö Cookies µÄÃû×Ö£¬ºÍËüµÄÖµ¡£ÀýÈ磬ÔÚijÎĵµÖÐÌí¼Ó“document.write(documents.cookie)”£¬½á¹ûÏÔʾ£º
name=kevin; email=kevin@kevin.com; lastvisited=index.html
ÕâÒâζ×Å£¬Îĵµ°üº¬ 3 ¸ö Cookies£ºname, email ºÍ lastvisited£¬ËüÃǵÄÖµ·Ö±ðÊÇ kevin, kevin@kevin.com ºÍ index.html¡£¿ÉÒÔ¿´µ½£¬Á½¸ö Cookies Ö®¼äÊÇÓ÷ֺźͿոñ¸ô¿ªµÄ£¬ÓÚÊÇÎÒÃÇ¿ÉÒÔÓà cookieString.split('; ') ·½·¨µÃµ½Ã¿¸ö Cookie ·Ö¿ªµÄÒ»¸öÊý×飨ÏÈÓà var cookieString = documents.cookie£©¡£
¡¡¡¡É趨һ¸ö Cookie µÄ·½·¨ÊÇ¶Ô documents.cookie ¸³Öµ¡£ÓëÆäËüÇé¿öϵĸ³Öµ²»Í¬£¬Ïò documents.cookie ¸³Öµ²»»áɾ³ýµôÔÓÐµÄ Cookies£¬¶øÖ»»áÔöÌí Cookies »ò¸ü¸ÄÔÓÐ Cook
Ïà¹ØÎĵµ£º
javascriptÊDz»ÄÜÖ±½Ó±È½ÏÁ½¸öÊý×éÊÇ·ñÏàµÈµÄ¡£ÀýÈ磺
var a = [1,2,3];
var b = [1,2,3];
alert(a == b); // false
½á¹ûÊÇ false. Ö¤Ã÷Á½¸öÊý×é²»ÄÜÖ±½Ó±È½ÏÏàµÈ¡£
½â¾ö·½·¨Ò»£º
ÏÈÅÅÐò£¬ÔÙÀûÓÃtoString·½·¨£¬±È½Ï¡£ÀýÈ磺
var a = [1,2,3];
var b = [1,2,3];
alert(a.sort().toString() ......
·â×°£ºÍ¨¹ý±Õ°ü²ÅËãµÄÉÏÊÇÕæÕýÒâÒåÉϵķâ×°
<script type="text/javascript">
function myInfo(){
var name ="ÀÏÓã",age =27;
var myInfo = "my name is" + name + "i am" + age  ......
ÕâÀïÃæµÄreturnº¬ÓÐһЩϸ½Ú֪ʶ£º
ÀýÈ磺onClick='return add_onclick()'Óë onClick='add_onclick()'µÄÇø±ð
JAVASCRIPTÔÚʼþÖе÷Óú¯ÊýʱÓÃreturn·µ»Øֵʵ¼ÊÉÏÊǶÔwindow.event.returnvalue½øÐÐÉèÖá£
¶ø¸ÃÖµ¾ö¶¨Á˵±Ç°²Ù×÷ÊÇ·ñ¼ÌÐø¡£
µ±·µ»ØµÄÊÇtrueʱ£¬½«¼ÌÐø²Ù×÷¡£
µ±·µ»ØÊÇfalseʱ£¬½«ÖжϲÙ×÷¡£
¶øÖ±½ÓÖ´ÐÐʱ£ ......
¾³£»áÔÚjsÀïÓõ½Êý×é,±ÈÈç ¶à¸öÃû×ÖÏàͬµÄinput, ÈôÊǶ¯Ì¬Éú³ÉµÄ, Ìύʱ¾ÍÐèÒªÅжÏÆäÊÇ·ñÊÇÊý×é.
if(document.mylist.length != "undefined" ) {} Õâ¸öÓ÷¨ÓÐÎó.
ÕýÈ·µÄÊÇ if( typeof(document.mylist.length) != "undefined" ) {}
»ò if( !isNaN(document.mylist.length) ) {}
typeofµÄÔËËãÊý䶨Òå,·µ»ØµÄ¾ÍÊÇ "u ......