Javascript-форум (https://javascript.ru/forum/)
-   Internet Explorer (https://javascript.ru/forum/css-html-internet-explorer/)
-   -   ie7 и удаление невидимых ячеек (https://javascript.ru/forum/css-html-internet-explorer/9937-ie7-i-udalenie-nevidimykh-yacheek.html)

x-yuri 11.06.2010 23:00

ie7 и удаление невидимых ячеек
 
выяснилось 2 вещи:
1) нельзя удалять невидимые ячейки
2) при удалении ячеек ie7 назначает всем невидимым один и тот же cellIndex (на один больше max(cellIndex) видимых ячеек), но оставляет на том же месте в коллекции HTMLTableRowElement.cells (это та самая всеми любимая дружелюбность по отношению к пользователю?)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
    <title>title</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>

<table>
<tr><td id="cell-1">
</tr>
</table>
<script type="text/javascript">
    var cell1 = document.getElementById('cell-1');
    cell1.style.display = 'none';
    cell1.parentNode.deleteCell( cell1.cellIndex );
</script>

</body>
</html>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
    <title>title</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>

<table>
<tr id="row"><td id="cell-1"><td id="cell-2"><td id="cell-3"><td id="cell-4"><td id="cell-5">
</tr>
</table>
<script type="text/javascript">
    var cell1 = document.getElementById('cell-1');
    cell1.style.display = '';
    document.getElementById('cell-3').style.display = 'none';
    document.getElementById('cell-4').style.display = 'none';
    cell1.parentNode.deleteCell( cell1.cellIndex );
    showCells();
    
    function showCells(){
        var cells = document.getElementById('row').cells;
        var r = [];
        for( var i=0; i<cells.length; i++ )
            r.push( cells[i].cellIndex );
        alert( r );
    }
</script>

</body>
</html>

Octane 11.06.2010 23:13

Что же творилось в головах разработчиков…


Часовой пояс GMT +3, время: 13:43.