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

ÉîÈëÈÏʶjavascriptÖеÄevalº¯Êý

ÉîÈëÈÏʶjavascriptÖеÄevalº¯Êý
·ÖÀࣺ¼¼ÊõרÇøʱ¼ä£º2007-5-21 15:04:58×÷ÕߣºsupNate  
         ·¢ÏÖΪ±¾ÎÄÆðÒ»¸öºÏÊʵıêÌ⻹²»ÊÇÄÇôÈÝÒ×£¬ºÇºÇ£¬ËùÒÔÔÚ´ËÏÈ˵Ã÷ϱ¾ÎĵÄÁ½¸öÄ¿µÄ£º
£¨1£©½éÉÜjavascriptÖеÄevalº¯ÊýµÄÓ÷¨
£¨2£©ÈçºÎÔÚº¯ÊýÄÚÖ´ÐÐÈ«¾Ö´úÂë
►ÏÈÀ´ËµevalµÄÓ÷¨£¬ÄÚÈݱȽϼòµ¥£¬ÊìϤµÄ¿ÉÒÔÌø¹ý¡£
evalº¯Êý½ÓÊÕÒ»¸ö²ÎÊýs£¬Èç¹ûs²»ÊÇ×Ö·û´®£¬ÔòÖ±½Ó·µ»Øs¡£·ñÔòÖ´ÐÐsÓï¾ä¡£Èç¹ûsÓï¾äÖ´Ðнá¹ûÊÇÒ»¸öÖµ£¬Ôò·µ»Ø´ËÖµ£¬·ñÔò·µ»Øundefined¡£
ÐèÒªÌرð×¢ÒâµÄÊǶÔÏóÉùÃ÷Óï·¨“{}”²¢²»ÄÜ·µ»ØÒ»¸öÖµ£¬ÐèÒªÓÃÀ¨ºÅÀ¨ÆðÀ´²Å»á·µ»ØÖµ£¬¼òµ¥Ê¾ÀýÈçÏ£º
var code1='"a" + 2';    //±í´ïʽ
var code2='{a:2}';      //Óï¾ä
alert(eval(code1));     //->'a2'
alert(eval(code2));     //->undefined
alert(eval('(' + code2 + ')'));    //->[object Object]
        ¿ÉÒÔ¿´µ½£¬¶ÔÓÚ¶ÔÏóÉùÃ÷Óï¾äÀ´Ëµ£¬½ö½öÊÇÖ´ÐУ¬²¢²»ÄÜ·µ»ØÖµ¡£ÎªÁË·µ»Ø³£Óõē{}”ÕâÑùµÄ¶ÔÏóÉùÃ÷Óï¾ä£¬±ØÐëÓÃÀ¨ºÅÀ¨×¡£¬ÒÔ½«Æäת»»Îª±í´ïʽ£¬²ÅÄÜ·µ»ØÆäÖµ¡£ÕâÒ²ÊÇʹÓÃJSONÀ´½øÐÐAjax¿ª·¢µÄ»ù±¾Ô­ÀíÖ®Ò»¡£ÔÚÀý×ÓÖпÉÒÔÇå³þµÄ¿´µ½£¬µÚ¶þ¸öalertÓï¾äÊä³öµÄÊÇundefined£¬¶øµÚÈý¸ö¼ÓÁËÀ¨ºÅºóÊä³öµÄÊÇÓï¾ä±íʾµÄ¶ÔÏó¡£
            ►ÏÖÔÚÀ´Ëµ±¾ÎĵÄÖص㣬ÈçºÎÔÚº¯ÊýÄÚÖ´ÐÐÈ«¾Ö´úÂ롣ΪÁË˵Ã÷Õâ¸öÎÊÌ⣬ÏÈ¿´Ò»¸öÀý×Ó£º
var s='global';    //¶¨ÒåÒ»¸öÈ«¾Ö±äÁ¿
function demo1(){
    eval('var s="local"');
}
demo1();
alert(s);    //->global
         ºÜºÃÀí½â£¬ÉÏÃæµÄdemo1º¯ÊýµÈ¼ÛÓÚ£ºfunction demo1(){var s='local';}£¬ÆäÖж¨ÒåÁËÒ»¸ö¾Ö²¿±äÁ¿s¡£
        ËùÒÔ×îºóµÄÊä³öÊÇglobal²¢²»ÊÇʲôÆæ¹ÖµÄÊÂÇ飬±Ï¾¹´ó¼Ò¶¼ÄܺÜÇå³þµÄÇø·Ö¾Ö²¿±äÁ¿ºÍÈ«¾Ö±äÁ¿¡£
        ×ÐϸÌå»áһϣ¬¿ÉÒÔ·¢ÏÖev


Ïà¹ØÎĵµ£º

Javascript ÅжÏä¯ÀÀÆ÷

                var Sys = {};
                var ua = navigator.userAgent.toLowerCase();
         &nbs ......

javascriptʼþ from PPK yahooÑݽ²

תÔØ×Ô£ºhttp://www.zipeng.info/archives/ppk-on-js-events.html
½ñÌìÎÒ»á˵һЩ¹ØÓÚJavaScriptʼþµÄÊÂÇ飬ÎÒºÜÏ£Íû×Ô¼ºÄÜÆô·¢´ó¼ÒһЩʲô£¬²»¹ý´ó»ï¶¼ÊǸßÊÖ£¬²»¹ÜÔõô£¬ÎÒ»¹ÊÇҪ˵˵
JavaScriptʼþ¡£
´óÔ¼Ò»ÄêÇ°ÎÒ´òËã¶ÔJavaScriptµÄʼþ×öһЩÉîÈëµÄÑо¿£¬²¢ÇÒÎÒ×öÁËÒ»ÕżæÈÝÐÔµÄ±í£¬´ó¼Ò¿ÉÒÔͨ¹ýÏÂÃæÕâÀïÀ´
·ÃÎ ......

Ïêϸ½â¶ÁJavaScriptµÄthis¹Ø¼ü×Ö


ÓÃÁ˺ܾÃJavaScript£¬¶Ô¡¾this¡¿µÄÈÏʶֻ¾ÖÏÞÓÚÒÔÍùµÄƾ¾­Ñé¶øÒÑ£¬²»¹ý½ñÌì·¢ÏÖÁ˺ö«Î÷“http://www.quirksmode.org/js/associative.html”£¬ÏêϸÃèÊöÁËÈçºÎʹÓá¾this¡¿¹Ø¼ü×Ö£¬ÔÚÕâÀïÎҾͼò¶ÌµÄ˵һÏÂÖص㣬Èç¹ûÓÐÒÉÎÊ¿ÉÒÔÖ±½Ó²Î¿¼Ô­ÎÄ¡£
ÔÚѧϰ¹ýÓÐthisµÄ±à³ÌÓïÑÔÖУ¬thisÒ»°ã¶¼ÊÇÖ¸Ïòµ±Ç°ÊµÀý¶ÔÏóµÄ£¬¶ÔÓ ......

һЩ±È½Ï³£¼ûµÄJavascript¿ò¼Ü¼ò½é

Dojo
      Ò»¸öÇ¿´óµÄÃæÏò¶ÔÏójavascript¿ò¼Ü¡£
      Ö÷ÒªÓÉÈý´óÄ£¿é×é³É£ºCore¡¢Dijit¡¢DojoX¡£
      CoreÌṩ Ajax£¬events£¬packaging£¬CSS-based querying£¬animations£¬JSONµÈÏà¹Ø²Ù×÷API¡£
      Dijit ......

.netºÍjavascript ÕýÔò±í´ïʽµÄ¶Ô±È

javascript
ÉùÃ÷:1.var reg=new Regex("^±í´ïʽ$","²ÎÊý") 2.ÄäÃû(JSonµÄд·¨) /±í´ïʽ/²ÎÊý,Èç:/±í´ïʽ/gi
×¢Òâ:¶þÖÖÉùÃ÷ÊǵÈЧµÄ,ÒÔÏÂʹÓÃregµÄλÖÃ,Ò²¿ÉÓÃ"ÄäÃû"Ìæ»».
Ìæ»»:
var str="×Ö·û´®";
var str2= str.replcace(reg»òÄäÃû,"Ìæ»»³ÉµÄ×Ö·û´®")
ÕÒ³öËùÓаüº¬µÄ:
var str="×Ö·û´®";
var arr=str.match(r ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ