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

JavascriptÖÐevalº¯ÊýµÄÓ÷¨

Ç°×ࣺ
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µÄÖµ.
ing¡£¡£¡£
ÓÐÐí¶àСÇÏÃÅÀ´Ê¹±à³Ì¸ü¼ÓÈÝÒס£ÆäÖÐÖ®Ò»¾ÍÊÇeval()º¯Êý£¬Õâ¸öº¯Êý¿ÉÒÔ°ÑÒ»¸ö×Ö·û´®µ±×÷Ò»¸öJavaScript±í´ïʽһÑùÈ¥Ö´ÐÐËü¡£ÒÔÏÂÊÇËüµÄ˵Ã÷
Eval º¯Êý
¹¦ÄÜ£ºÏȽâÊÍJavascript´úÂ룬ȻºóÔÚÖ´ÐÐËü
Ó÷¨£ºEval(codeString)
codeStringÊÇ°üº¬ÓÐ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¡£
Õâ¸ö¿´ÆðÀ´ËƺõÓеãɵ£¬Æäʵ¿ÉÒÔ×ö³öºÜÓÐȤµÄÊ¡£±ÈÈçʹÓÃevalÄã¿ÉÒÔ¸ù¾ÝÓû§µÄÊäÈëÖ±½Ó´´½¨º¯Êý¡£Õâ¿ÉÒÔʹ³ÌÐò¸ù¾Ýʱ¼ä»òÓû§ÊäÈëµÄ²»Í¬¶øʹ³ÌÐò±¾Éí·¢Éú±ä»¯£¬Í¨¹ý¾ÙÒ»·´Èý£¬Äã¿ÉÒÔ»ñµÃ¾ªÈ˵ÄЧ¹û¡£
ÔÚʵ¼ÊÖУ¬evalºÜÉÙ±»Óõ½£¬µ«Ò²ÐíÄã¼û¹ýÓÐÈËʹÓÃevalÀ´»ñÈ¡ÄÑÒÔË÷ÒýµÄ¶ÔÏó¡£ Îĵµ¶ÔÏóÄ£ÐÍ£¨DOM)µÄÎÊÌâÖ®Ò»ÊÇ:ÓÐʱÄãÒª»ñÈ¡ÄãÒªÇóµÄ¶Ô


Ïà¹ØÎĵµ£º

javascriptѧϰËæ±Ê(ʹÓÃwindowºÍframe)µÄ¼¼ÇÉ

JavaScriptÔÊÐí´´½¨ºÍ´ò¿ª´ú±íHTMLÎı¾, form¶ÔÏóºÍframeµÄ´°¿Ú. window¶ÔÏóÊÇJavaScript¿Í»§²ã´Î½á¹¹µÄ×²ã¶ÔÏó, formÔªËغÍÈ«²¿JavaScript´úÂ붼ÊÇ´æÔÚÓÚÎĵµÖÐ,¶øÎĵµ±»×°Ôؽø´°¿Ú. ΪÁËÀí½â´°¿ÚÔõÑù¹¤×÷,Äã¿ÉÒÔ¿ØÖƲÙ×÷ÕâЩ´°¿Ú.
´ò¿ªºÍ¹Ø±Õ´°¿Ú
µ±Óû§Æô¶¯(launch)Navigatorʱ,½«×Ô¶¯´´½¨Ò»¸ö´°¿Ú.Óû§»¹¿ÉÒÔÊ¹Ó ......

javascript±ä»¯µÄʱÖÓ

<script language="JavaScript">
<!--
function check(val){
 if (val<10){
  return("0"+val);
 }else{
  return(val);
 }
}
function ShowTime()
{
 var date=new Date();
 var year=date.getFullYear();
 var month=date.getMont ......

ʹÓÃCDHtmlDialog £¬ÊµÏÖjavascript µ÷ÓÃC++

.h Îļþ
class CHtmlSkinDlg : public CDHtmlDialog
{
      ¡£¡£¡£¡£¡£
    DECLARE_DISPATCH_MAP()     
//  !!! ¸²¸Ç»ùÀàµÄÕâ¸ö·½·¨
BOOL CanAccessExternal()
    {
        ......

JSONÓëString»¥×ª£¨javascript£©

JSON => String:
function jsonToString(obj){
var THIS = this;
switch(typeof(obj)){
case 'string':
return '"' + obj.replace(/(["\\])/g, '\\$1') + '"';
case 'array':
return '[' + obj.map(THIS.jsonToStri ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ