Num=1002;
Content ="";//原笨办法。如果有特殊符号,我想会出问题.
x_C("x(\""+Num+"\",\""+Content +"\")");
function x_C(_str) {
    setTimeout(_str, myRandom(500, 1000));}
//想结合eval使用,高手指点哈,老出错
x_C(Num,Content);
function x_C(Num,Content) {
    setTimeout(eval("FunNumHtml_" + Num + "(Content);"), myRandom(500, 1000));
    //有问题 :(
}

解决方案 »

  1.   

    干嘛要eval?<html>
    <head><title></title></head>
    <body>
    <script>
    function x_1(content){
    alert(content);
    }var n = 1;
    var c = 'hello world';
    function x_C(n,c){
    setTimeout("x_"+n+"('"+c+"')",1000);
    }
    x_C(n,c);
    </script>
    </body>
    </html>
      

  2.   

    function x_C(Num,Content) {
        (function(n, c){
         c = c.replace(/([\n'"\\])/ig,"\\$1");
           setTimeout(function(){eval("FunNumHtml_" + n + "('"+ c + "');");}, myRandom(500, 1000))
        })(Num,Content);
    }
      

  3.   

    c = c.replace(/([\n'"\\])/ig,"\\$1");
    ....
    需要过滤掉什么?给个正确的说明和代码~