通过javascript生成的动态HTML - onClick除IE之外的其他浏览器中不起作用

时间:2012-05-02 17:41:17

标签: asp.net html dynamic-html

下面列出的是一个动态html代码,它在运行时生成并放入我的应用程序中。在IE中这很好但在其他浏览器中没有。问题是当单击tbl或img项时,onclick事件永远不会发生。我可以通过在应该调用的函数的开头运行跟踪点但不发生任何事情来说明这一点。这可能是格式化问题。要点击的ID是tbl72635和img72635。点击任何一个都没有任何反应。图像是表格内部的加号减号框 - 当图像被点击时,树会展开并显示下一行,但是当单击表格行的其余部分时,它会打开包含信息的显示页面。点击上的这些操作都不能在IE之外的任何其他浏览器中工作谢谢你的帮助。

<div id="div027" style="display:block"><table border=0 class="DetailsOther" id="tbl72635" EntityID="726" 
EntityCat="35" ParentEntityID="0" ParentEntityCat="35" width=100% border=0 cellpadding=1 cellspacing=0 
onclick="entityclick(this);" onmouseup="rightClick(726,35, 'Lev 7     ')"><tr><td width=1% nowrap=true 
valign=top align=left id="td72635" fav=0 ><img src="../images/R.gif"><img src='../images/paperclipblank.gif' />
<img src="../images/fileattachblank.gif"><img src="../images/Check_Done_bl.gif"></td><td width=31% align=left valign=top >
<img canExpand="true" style="cursor:hand" id="img72635" src="../images/plus.gif" EntityID="726" EntityCat="35" 
onclick="LoadChild(this.EntityID, this.EntityCat, 0, this.lnEquip);
">Lev 7     -726: Level 7 - Test #3 <font id="img" style="cursor:hand;font-size:8pt;color:blue;text-decoration:underline" 
onclick="LoadDescription(726,35)">...</font></td><td width=11% valign=top align=left><br><font color="darkblue" align=left></font></td>
<td width=9% valign=top align=left></td>
<td width=10% valign=top align=left>SSI Admin</td>
<td width=9% nowrap=true valign=top align=center  style="padding-left:6px">Feb 06, 12<br><font color=maroon>Feb 28, 12</font></td>
<td width=9% nowrap=true valign=top align=center>Mar 30, 12<br><font color=maroon>Apr 09, 12</font></td>
<td width=6% nowrap=true valign=top align=right>168 H<br><font color=darkblue>40 D</font></td>
<td width=11% align=left valign=top style="padding-left:9px"></td></tr>
<tr><td>
</td><td colspan=10 align=left ><div whattype="DescDiv" status="0" id="divDesc72635" style="display:none;padding-left:13px"><font style="color:navy;font-size:8pt"><u>Description:</u> Test description</font></div></td></tr></table>
<div id="div72635" style="display:none"><font color="green">Loading tree.....</font></div></div>

谢谢。

以下是loadChild的代码

            function LoadChild(lnEntityID, lnEntityCat, FullExpand, EquipID) {

            document.getElementById('dropTypes').disabled = false;
            document.getElementById('dropTypes').style.background = "white";
            DescStatus = 0;

            if (lnEntityCat == 0) {

                window.status = "Loading the tree...";
                PageMethods.LoadChild(lnEntityID, lnEntityCat, GLOBALEQUIPID, FullExpand, 0, 0, 1, LoadChildCallback);
            }
            else if (document.getElementById('img' + lnEntityID + lnEntityCat).canExpand == "true") {
                if (document.getElementById('div' + lnEntityID + lnEntityCat).style.display == 'none') {
                    document.getElementById('div' + lnEntityID + lnEntityCat).style.display = 'block';
                    document.getElementById('img' + lnEntityID + lnEntityCat).src = "../images/minus.gif"
                    window.status = "Loading the tree...HERE";
                    PageMethods.LoadChild(lnEntityID, lnEntityCat, GLOBALEQUIPID, FullExpand, 0, 0, 1, LoadChildCallback);
                }
                else {
                    document.getElementById('div' + lnEntityID + lnEntityCat).style.display = 'none';
                    document.getElementById('img' + lnEntityID + lnEntityCat).src = "../images/plus.gif"
                }
            }
        }

这是entityclick的代码

            function entityclick(where, e) {
            var evt;
            if (window.event)
                evt = window.event; 
            else
                evt = e.which; 


            try {
                var tempstring = new String(evt.srcElement.id)
                tempstring = tempstring;
                }
            catch (oExp) {
                var tempstring = new String("noclickyclicky")
            }
            tempstring = tempstring.substr(0, 3)
            if (tempstring != "img") {
                if (selectedentity != "") {
                    try {
                        document.getElementById('tbl' + selectedentity).style.backgroundColor = ""
                    }
                    catch (oExc) {

                    }
                }

                selectedentity = where.EntityID + where.EntityCat;
                var EntityID = where.EntityID
                var EntityCat = where.EntityCat
                var ParentEntityID = where.ParentEntityID
                var ParentEntityCat = where.ParentEntityCat
                var projtype = 0

                ifram = document.getElementById('detailframe')

                if (0 == 0) {
                    if (EntityCat == 35)
                        ifram.src = "../teams/Viewteam.aspx?taskgrpid=" + EntityID + "&taskgrpcategory=" + EntityCat + "&ptaskgrpid=" + ParentEntityID + "&ptaskgrpcategory=" + ParentEntityCat + "&taskgrptype=" + GLOBALTASKGRPTYPE;
                    else if (EntityCat == 26)
                        ifram.src = "../teams/Viewteam.aspx?taskgrpid=" + EntityID + "&taskgrpcategory=" + EntityCat + "&ptaskgrpid=" + ParentEntityID + "&ptaskgrpcategory=" + ParentEntityCat + "&taskgrptype=" + GLOBALTASKGRPTYPE;
                    else if (EntityCat == 34)
                        ifram.src = "../teams/Viewteam.aspx?taskgrpid=" + EntityID + "&taskgrpcategory=" + EntityCat + "&ptaskgrpid=" + ParentEntityID + "&ptaskgrpcategory=" + ParentEntityCat + "&taskgrptype=" + GLOBALTASKGRPTYPE;
                    else if (EntityCat == 10)
                        ifram.src = "../solutions/ViewSolution.aspx?taskgrpid=" + EntityID + "&taskgrpcategory=" + EntityCat + "&ptaskgrpid=" + ParentEntityID + "&ptaskgrpcategory=" + ParentEntityCat + "&taskgrptype=" + GLOBALTASKGRPTYPE;
                    else if (EntityCat == 11)
                        ifram.src = "../observations/ViewObservation.aspx?taskgrpid=" + EntityID + "&taskgrpcategory=" + EntityCat + "&ptaskgrpid=" + ParentEntityID + "&ptaskgrpcategory=" + ParentEntityCat;
                    else if (EntityCat == 12)
                        ifram.src = "../actions/ViewAction.aspx?taskgrpid=" + EntityID + "&taskgrpcategory=" + EntityCat + "&ptaskgrpid=" + ParentEntityID + "&ptaskgrpcategory=" + ParentEntityCat;
                    else if (EntityCat == 13)
                        ifram.src = "../tasks/ViewTask.aspx?taskgrpid=" + EntityID + "&taskgrpcategory=" + EntityCat + "&ptaskgrpid=" + ParentEntityID + "&ptaskgrpcategory=" + ParentEntityCat;
                    ifram.style.left = '27%'
                    ifram.style.display = 'block'
                    ifram.style.zIndex = 5
                }
            }
        }

0 个答案:

没有答案