gpt4 book ai didi

javascript - tr 显示无崩溃 ie9

转载 作者:数据小太阳 更新时间:2023-10-29 04:09:24 24 4
gpt4 key购买 nike

此代码使 ie9 崩溃,因为我在我的代码中遇到了这个问题..任何变通方法将不胜感激..这不是 ie 以前版本的问题..谢谢..

<?xml version="1.0" encoding="UTF-8"?>
<!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" xml:lang="en">
<head></head>
<body>
<table style="border-collapse: collapse">
<tr id="firsttr">
<td colspan="2"></td>
<td></td>
</tr>
<tr id="secondtr">
<td></td>
<td style="border: 1px solid #D2D2D2">Move cursor here</td>
<td></td>
</tr>
</table>
</body>
<style type="text/css">
#secondtr:hover {
display: none;
}

</style>
</html>

即使使用 onclick 事件也会使浏览器崩溃..尝试以下.. 将光标移至此处

    <script type="text/javascript">
function HideThis()
{
document.getElementById('secondtr').style.display = 'none';
}
</script>

最佳答案

我也遇到了同样的问题,已经找到解决办法了。首先,我应该说,对于 IE9 中样式 borderCollapse 等于 collapse 的表中的任何行(无论它是声明为内联还是在 head 中),问题都是实际的。

我的解决方案:

function hideRow(tableNode, rowNode, hide){
if(hide){
if(window.navigator.userAgent.search('MSIE 9.0') != -1){
var initValue = tableNode.style.borderCollapse;
tableNode.style.borderCollapse = 'separate';
rowNode.style.display = 'none';
tableNode.style.borderCollapse = initValue;
}else{
rowNode.style.display = 'none';
}
}else{
rowNode.style.display = '';
}
}

甚至缩短:

function hideRow(tableNode, rowNode, hide){
var initValue = tableNode.style.borderCollapse;
tableNode.style.borderCollapse = 'separate';
rowNode.style.display = hide ? 'none' : '';
tableNode.style.borderCollapse = initValue;
}

关于javascript - tr 显示无崩溃 ie9,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11326697/

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