gpt4 book ai didi

javascript - IE Javascript 点击问题

转载 作者:行者123 更新时间:2023-11-30 09:10:20 25 4
gpt4 key购买 nike

首先,我正在开发一个应用程序,该应用程序的编写使得一些典型的调试工具无法使用(或者至少我不知道如何使用 :)。

JavaScript、html 等在部署之前都是“煮熟”和编码的(我想;我对过程的工作原理有点模糊),所以我无法将 VS 2005 附加到 ie,firebug lite 也没有好好工作。此外,界面是在框架中的(糟糕),所以其他一些工具也不能正常工作。

Firebug 在 Firefox 中工作得很好,它没有这个问题(Safari 也没有),所以我希望有人会发现我的代码在 IE 上运行的方式“明显”有问题。关于它的古怪之处,可以提供更多信息,但让我们从这里开始。

基本上,我有一个功能,可以通过使普通表格行不可见来将表格“折叠”到它们的标题中。我有"onclick='toggleDisplay("theTableElement", "theCollapseImageElement")'"<tr>标签和表格以“class='closed'”开头。

在 FF 和 Safari 中单击一次即可折叠和展开表格,但 IE 表格需要多次单击(看似 1 到 5 之间的任意数字)才能展开。有时,在最初“打开”之后,表格会通过一次单击展开和折叠一小会儿,但最终会恢复到需要多次单击的状态。我可以从我在 Visual Studio 中看到的一点点信息看出,实际上每次都达到了该功能。在此先感谢您的任何建议!

这是JS代码:

bURL_RM_RID="some image prefix";
CLOSED_TBL="closed";
OPEN_TBL="open";
CLOSED_IMG= bURL_RM_RID+'166';
OPENED_IMG= bURL_RM_RID+'167';

//collapses/expands tbl (a table) and swaps out the image tblimg
function toggleDisplay(tbl, tblimg) {
var rowVisible;
var tblclass = tbl.getAttribute("class");
var tblRows = tbl.rows;
var img = tblimg;

//Are we expanding or collapsing the table?
if (tblclass == CLOSED_TBL) rowVisible = false;
else rowVisible = true;

for (i = 0; i < tblRows.length; i++) {
if (tblRows[i].className != "headerRow") {
tblRows[i].style.display = (rowVisible) ? "none" : "";
}
}

//set the collapse images to the correct state and swap the class name
rowVisible = !rowVisible;
if (rowVisible) {
img.setAttribute("src", CLOSED_IMG);
tbl.setAttribute("class",OPEN_TBL);
}
else {
img.setAttribute("src", OPENED_IMG);
tbl.setAttribute("class",CLOSED_TBL);
}
}

最佳答案

你试过改变这条线

tblRows[i].style.display = (rowVisible) ? "none" : "";

类似于

tblRows[i].style.display = (rowVisible) ? "none" : "table-row";

tblRows[i].style.display = (rowVisible) ? "none" : "auto";

关于javascript - IE Javascript 点击问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/102261/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com