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

javascriptÖеÄeval

javascriptÖÐevalÏêϸÀí½â
2009-02-27 14:58
2008-04-12 00:29
Ê×ÏÈÀ´¸ö×î¼òµ¥µÄÀí½â
eval¿ÉÒÔ½«×Ö·û´®Éú³ÉÓï¾äÖ´ÐУ¬ºÍSQLµÄexec()ÀàËÆ¡£
    evalµÄʹÓó¡ºÏÊÇʲôÄØ£¿ÓÐʱºòÎÒÃÇÔ¤ÏȲ»ÖªµÀÒªÖ´ÐÐʲôÓï¾ä£¬Ö»Óе±Ìõ¼þºÍ²ÎÊý¸øʱ²ÅÖªµÀÖ´ÐÐʲôÓï¾ä£¬Õâʱºòeval¾ÍÅÉÉÏÓó¡ÁË¡£¾Ù¸öÀý×Ó£º
     ÎÒÃÇÒª×öÒ»¸öfunction()£¬¹¦ÄÜÊÇÊäÈëÍøÒ³ÖÐÁ½¸ö¸ö¶ÔÏóµÄÃû³Æ£¬È»ºó³ÌÐò¾Í½«ÕâÁ½¸ö¶ÔÏóµÄÖµÁª½ÓÆðÀ´Êä³ö¡£
function output(a,b)
{
   var tmpa,tmpb;
   tmpa=document.all.a.value;
   tmpb=document.all.b.value;
   document.write(tmpa+tmpb);
}
output('input1','input2');
       ÕâÑùÄãÖ´ÐеÄʱºò¾Í»áÌáʾ´íÎó“document.all.a²»ÊǶÔÏó”ÒÔ¼°“document.all.b²»ÊǶÔÏó”¡£Ô­À´javascript°ÑaºÍbµ±³É¶ÔÏóÃû³ÆÁË£¬ÔõÑùÄÜÈÃjavascript°ÑaÀïÃæµÄÖµ×÷Ϊ¶ÔÏóÃû³ÆÄØ£¿Õâʱºò¾ÍÒªÓÃevalÁË£¬°Ñ´úÂë¸Ä³ÉÕâÑù£º
function output(a,b)
{
var tmpa,tmpb;
tmpa=eval("document.all."+a+".value");
tmpb=eval("document.all."+b+".value");
document.write(tmpa+tmpb);
}
output('input1','input2');
ÕâÑùjavascript¾Í»áÏÈÈ¡³öa,bµÄÖµ£¬È»ºóºÍÇ°ÃæµÄdocument.all.ÒÔ¼°ºóÃæµÄ.value×éºÏÔËÐУ¬ÓÚÊǾͿÉÒÔ
˳ÀûÈ¡³öinput1ºÍinput2µÄÖµ.
¿´ÍêÉÏÃæµÄ»ù±¾Àí½âevalÊÇʲôº¬ÒåÁË°É
È»ºó¿´ÏÂÃæµÄÀí½â
ÉÔ΢½ú¼¶Ò»µãµã£¬Óõ½ÁËDOMÖÐÌ滻ͼƬµÄÀý×Ó
ÔÚJavascriptÖÐEvalº¯ÊýµÄʹÓã¿
¡¾eval()º¯Êý¡¿
À´Ô´£ºhttp://blog.csdn.net/ianc/archive/2006/05/29/761094.aspx
JavaScriptÓÐÐí¶àСÇÏÃÅÀ´Ê¹±à³Ì¸ü¼ÓÈÝÒס£
ÆäÖÐÖ®Ò»¾ÍÊÇeval()º¯Êý£¬Õâ¸öº¯Êý¿ÉÒÔ°ÑÒ»¸ö×Ö·û´®µ±×÷Ò»¸öJavaScript±í´ïʽһÑùÈ¥Ö´ÐÐËü¡£
¾Ù¸öСÀý×Ó£º
var the_unevaled_answer = "2 + 3";
var the_evaled_answer = eval("2 + 3");
alert("the un-evaled answer is " + the_unevaled_answer + " and the evaled answer is " + the_evaled_answer);
Èç¹ûÄãÔËÐÐÕâ¶Îeval³ÌÐò, Ä㽫»á¿´µ½ÔÚJavaScriptÀï×Ö·û´®"2 + 3"ʵ¼ÊÉϱ»Ö´ÐÐÁË¡£
ËùÒÔµ±Äã°Ñthe_evaled_answerµÄÖµÉè³É eval("2 + 3")ʱ, JavaScript½«»áÃ÷°×²¢°Ñ2ºÍ3µÄºÍ·µ»Ø¸øthe_evaled_answer¡£
Õâ¸ö¿´ÆðÀ´ËƺõÓеãɵ£¬Æäʵ¿ÉÒÔ×ö³öºÜÓÐȤµÄÊ¡£±ÈÈçʹÓÃeva


Ïà¹ØÎĵµ£º

ÕÅТÏêjavascript½²×ù±Ê¼Ç¶þ

Ò»£¬JavaScriptÖеı£Áô¹Ø¼ü×Ö
      abstract        extends         instanceof         static           & ......

javascriptÊäÈëÆ¥Åä

<style>
ul,li{margin: 0; padding: 0;width:100%;}
</style>
<script language="javascript" type="text/javascript">
function checkword()
{
   var wordvalue=document.getElementById("word").value.toLowerCase();
   var alltxt="admin¹ÜÀíÔ±|appleÆ»¹û|allÈ«|big´ó|b ......

javascript css cookie»»Æ¤·ô

һ˵µ½javascript¾ÍÓÐÈË»áÏëµ½java£¬µ«ÊÇËûÃÇÍê»áÊÇÁ½»ØÊ£¬javascriptÊÇÃæÏò¶ÔÏóµÄ¶¯Ì¬ÀàÐ͵ÄÇø·Ö´óСдµÄ¿Í»§¶Ë½Å±¾ÓïÑÔ£¬Çë×¢Òâ´óСÓÐÇø±ð£¬ÃæÏò¶ÔÏó¡£javascriptÓÃ;ºÜ¶àµÄ£¬Ä¿Ç°¼¸ºõËùÓÐÖ÷Á÷ä¯ÀÀÆ÷¶¼Ö§³Ö¡£µ«ÊÇËûÓÐÒ»¸ö»µ´¦¾ÍÊDZäÁ¿£¬Èçvar
i=4;Õâ¸öi¾ÍÊÇintÀàÐ͵ģ¬var
s="hello",Õâ¸ösÊÇ×Ö·û´®ÀàÐ͵ģ ......

javascriptÖеÄdefer

ÔÚʹÓÃgetElementByIdʱÓÖÓöµ½ÁË“document.getElementById('...')Ϊ¿Õ»ò²»ÊÇ·½·¨”µÄ´íÎó£¬alert()ÁËһϷ¢ÏÖ»ñÈ¡µÄֵΪnull£¬ÓÚÊÇÕÒÁË°ëÌìËÑË÷µ½ÁËÕâ¸öÕâ¸ödefer¡£
ÔÚjavascript±êÇ©ÖмÓÉÏ defer µÈÓÚÔÚÒ³ÃæÍêÈ«ÔÚÈëºóÔÙÖ´ÐУ¬Ï൱ÓÚ window.onload £¬µ«Ó¦ÓÃÉϱȠwindow.onload  ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ