比如 <script type="text/javascript">
    function x1(bo,re) {
        if (bo==1) {
            re;
        } else {
            //xxx
        }
     }     function x2() {
         document.getElementById('m').innerHTML = 'xx2';      }
     function x3() {
         document.getElementById('m').innerHTML = 'xx3';      }     x1(1, 'x2()');
     //x1(1, 'x3()');
</script>简单地说就是想让x2 x3根据不同情况插入x1  不过这样貌似不行提示我re没定义 不知道有没有什么解决方法

解决方案 »

  1.   

    可以!<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script type="text/javascript">
      function x1(bo,re) {
      re(bo);
      }  var x2=function(bo){
      if(bo==1){
      document.getElementById('m').innerHTML = 'xx2';
      }else{
      document.getElementById('m').innerHTML = 'xx3';
      }
      }
    </script>
    </head><body onload="x1(1,x2)">
    <div id="m"></div>
    </body>
    </html>
      

  2.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
    <script src="Ajax.js" type="text/javascript"></script>
    <script type="text/javascript">    var x3 = function (add) {
            document.getElementById('x3').innerHTML = 'x3';
        }
        postData("", 'Ajax.aspx?', x3, true);
    </script>
    </head><body><span id='x3'></span>   
    </body>
    </html>
    function createXml() {
        var xmlHttp;
        try { xmlHttp = new XMLHttpRequest(); }
        catch (e) {
            try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); }
            catch (e) {
                try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }
                catch (e) { alert("您的浏览器不支持AJAX!"); return false; }
            }
        }
        return xmlHttp;
    }
    function postData(postString, postUrl,Id,repfuc) {    var xmlHttp = createXml();
        xmlHttp.open("POST", postUrl + "&n=" + Math.random(), true);
        xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        xmlHttp.send(postString);
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4) {
                if (repfuc == true) {
                    id();
                } else {
                    document.getElementById(Id).innerHTML = xmlHttp.responseText;
                }        }
        }
        
        if (xmlHttp.readyState == 1) { //document.getElementById('out').innerText = '请求已提出(调用 send() 之前)';
            //document.getElementById(Id).innerHTML = "请求已提出";
        }
        if (xmlHttp.readyState == 2) { //document.getElementById('out').innerText = '请求已发送(这里通常可以从响应得到内容头部)';
            //document.getElementById(Id).innerHTML = "请求已发送";
        }
        if (xmlHttp.readyState == 3) { //document.getElementById('out').innerText = '请求处理中(响应中通常有部分数据可用,但是服务器还没有完成响应)';
            //document.getElementById(Id).innerHTML = "请求处理中";
        } }我的为啥还是提示找不到呢