应该为
function administrationNoticeInit(index)
{
alert(index);

着急忘了!
高手们帮帮忙啊!

解决方案 »

  1.   

    img.onclick = function() { new Function("administrationNoticeInit("+ i+" )") };查查闭包问题,上面只是一种解决方法,还有别的方法
      

  2.   

    试试这样呢
    function administrationNoticeMenuInit()
    {
        var row = document.createElement("tr");
        var cell=null,img=null; 
        for(var i=0;i<4;i++)
        {
            cell = document.createElement("td");
            img = document.createElement("img");
            img.setAttribute("id","administrationNotice"+i);
            img.setAttribute("src","../images/index1_0"+i+".jpg");
            if(document.uniqueID)
            {
                img.style.cssText = "cursor: hand;";   
            }
            else
            {
                img.setAttribute("style","cursor: hand;");
            }
            img.onclick = function() { administrationNoticeInit(this) };
            cell.appendChild(img);
            row.appendChild(cell);
        }
        administrationNoticeMenu.appendChild(row);
    }
    function administrationNoticeInit(o)
    {
    var id=o.getAttribute("id");
    var pos=id.substring(20); //
    alert(pos+":"+id);
    }
      

  3.   


    to mingxuan3000(铭轩):
    你的方法,测试了,没有任何反应!下面我把完整的函数写出来:
    function administrationNoticeMenuInit()
    {
        var data = AjaxClass.GetMenu(24);
        var row = document.createElement("tr");
        var cell=null,img=null,nodeId; 
        for(var i=0;i<data.value.Tables[0].Rows.length;i++)
        {
            cell = document.createElement("td");
            img = document.createElement("img");
            img.setAttribute("id","administrationNotice"+i);
            img.setAttribute("src","../images/index1_0"+i+".jpg");
            if(document.uniqueID)
            {
                img.style.cssText = "cursor: hand;";   
            }
            else
            {
                img.setAttribute("style","cursor: hand;");
            }
            nodeId = data.value.Tables[0].Rows[i].nodeId;
            img.onclick = function() { administrationNoticeInit( nodeId , i ) };        cell.appendChild(img);
            row.appendChild(cell);
        }
        administrationNoticeMenu.appendChild(row);
    }function administrationNoticeInit(nodeId,num)
    {
    alert(nodeId+"&"+num);    switch(num)
        {
            case 0:
                document.getElementById('administrationNotice0').src='../images/index2_00.jpg';
                document.getElementById('administrationNotice1').src='../images/index1_01.jpg';
                document.getElementById('administrationNotice2').src='../images/index1_02.jpg';
                document.getElementById('administrationNotice3').src='../images/index1_03.jpg';
            break;
            case 1:
                document.getElementById('administrationNotice0').src='../images/index1_00.jpg';
                document.getElementById('administrationNotice1').src='../images/index2_01.jpg';
                document.getElementById('administrationNotice2').src='../images/index1_02.jpg';
                document.getElementById('administrationNotice3').src='../images/index1_03.jpg';
            break;
            case 2:
                document.getElementById('administrationNotice0').src='../images/index1_00.jpg';
                document.getElementById('administrationNotice1').src='../images/index1_01.jpg';
                document.getElementById('administrationNotice2').src='../images/index2_02.jpg';
                document.getElementById('administrationNotice3').src='../images/index1_03.jpg';
            break;
            case 3:
                document.getElementById('administrationNotice0').src='../images/index1_00.jpg';
                document.getElementById('administrationNotice1').src='../images/index1_01.jpg';
                document.getElementById('administrationNotice2').src='../images/index1_02.jpg';
                document.getElementById('administrationNotice3').src='../images/index2_03.jpg';
            break;    }
        var data = AjaxClass.GetAdministrationNoticeList_Pre(nodeId);
        if(document.getElementById("administrationNotice").hasChildNodes())
        {
            var count = document.getElementById("administrationNotice").childNodes.length;
            for(var i=0;i<count;i++)
            {
                document.getElementById("administrationNotice").removeChild(document.getElementById("administrationNotice").childNodes[0]);
            }
        }
        setTbody_threeCell(data,31,"administrationNotice","../images/but3.jpg",1,"15px","455px");
    }需要传两个参数!
      

  4.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <META NAME="Generator" CONTENT="EditPlus">
    <META NAME="Author" CONTENT="">
    <META NAME="Keywords" CONTENT="">
    <META NAME="Description" CONTENT="">
    </HEAD><BODY><div id="result"><li>AAAAA</li>
    <li>BBBbb</li></div>
    <div id="a">test</div> <table><tr>
    <td><input type="checkbox" name="checks" onclick="changeValues(this)"><input type="hidden" name="hids" value="0"></td>
    <td><input type="text" name="t" value="aaaaa"></td>
    </tr>
    <tr>
    <td><input type="checkbox" name="checks" onclick="changeValues(this)"><input type="hidden" name="his" value="0"></td>
    <td><input type="text" name="t" value="bbb"></td>
    </tr>
    </table>
    <input type="button" name="aa" value="asdf" >
    <input type="button" name="aa" value="asdf" >
    <input type="button" name="aa" value="asdf" >
    <input type="button" name="aa" value="asdf" >
    <tr>===================================
    <input type="button" name="bb" value="asdf" >
    <input type="button" name="bb" value="asdf" >
    <input type="button" name="bb" value="asdf" >
    <input type="button" name="bb" value="asdf" >
    </BODY>
    <script language="javascript">function a(b,c){
    alert(b+c)
    }
    function b(){
    var bb=document.getElementsByName("aa")
    for(var i=0;i<4;i++){
       bb[i].onclick=function() { a("aa",i)}
    }
    }
    b()
    function c(){
    var dd=document.getElementsByName("bb")
    for(var ii=0;ii<4;ii++){
       dd[ii].onclick=(function(ii) { return function (){a("bb",ii)}})(ii)
    }
    }
    c()
    </script>
    </HTML>
      

  5.   

    Function的
    function a(b,c){
    alert(b+c)
    }
    function b(){
    var bb=document.getElementsByName("aa")
    for(var i=0;i<4;i++){
       bb[i].onclick=new Function("a('aa',"+i+")")
       //new Function("a('aa',"+i+")")
    }
    }
    b()
      

  6.   

    谢谢 mingxuan3000(铭轩) 
    问题已经解决!
    非常感谢!!!
    最后想问一下,这种方法除了IE以外的其他浏览器上也能正常使用吗?