最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jsTree display flaw in IE8 - Stack Overflow

programmeradmin1浏览0评论

I've been working with jsTree and encountered a problem in IE8. All the data is displayed correctly in the tree, but when I attempt to collapse a branch of the tree it does not display properly. That is, the smooth collapse animation happens, but then the data is again visible when it should not be.

The same code works great on Firefox 3.6.27 and Chrome 18.0.1025.151. Any idea why IE8 would behave differently?

Here is the code for the webpage:

<html>
<head>
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript" src="jstree/jquery.jstree.js"></script>
</head>
<body style="margin:0px">
    <script type="text/javascript">
        $(function() {
            $("#equipment_tree")
                .jstree({ "plugins" : ["themes","html_data","ui"] });
        });
    </script>
    <div id="equipment_tree" style="width:185px; float:left; height:100%; overflow:auto;">
        <ul>
            <li class="jstree-open"><a href="#">Root node 1</a>
                <ul>
                    <li><a href="#">Child node 1</a></li>
                    <li><a href="#">Child node 2</a></li>
                    <li><a href="#">Child node 3</a></li>
                    <li><a href="#">Child node 4</a></li>
                </ul></li>
            <li><a href="#">Root node 2</a></li>
        </ul>
    </div>
</body>
</html>

And also a picture of the erroneous behavior:

I've been working with jsTree and encountered a problem in IE8. All the data is displayed correctly in the tree, but when I attempt to collapse a branch of the tree it does not display properly. That is, the smooth collapse animation happens, but then the data is again visible when it should not be.

The same code works great on Firefox 3.6.27 and Chrome 18.0.1025.151. Any idea why IE8 would behave differently?

Here is the code for the webpage:

<html>
<head>
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript" src="jstree/jquery.jstree.js"></script>
</head>
<body style="margin:0px">
    <script type="text/javascript">
        $(function() {
            $("#equipment_tree")
                .jstree({ "plugins" : ["themes","html_data","ui"] });
        });
    </script>
    <div id="equipment_tree" style="width:185px; float:left; height:100%; overflow:auto;">
        <ul>
            <li class="jstree-open"><a href="#">Root node 1</a>
                <ul>
                    <li><a href="#">Child node 1</a></li>
                    <li><a href="#">Child node 2</a></li>
                    <li><a href="#">Child node 3</a></li>
                    <li><a href="#">Child node 4</a></li>
                </ul></li>
            <li><a href="#">Root node 2</a></li>
        </ul>
    </div>
</body>
</html>

And also a picture of the erroneous behavior:

Share Improve this question asked Apr 10, 2012 at 15:41 Dylan KlomparensDylan Klomparens 2,9727 gold badges38 silver badges54 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

You are missing the !DOCTYPE declaration. Add the following to the top of your page and that should fix the problem...

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3/TR/xhtml1/DTD/xhtml1-strict.dtd">

Read here about !DOCTYPE for IE.

This is perfect.

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3/TR/xhtml1/DTD/xhtml1-strict.dtd">
发布评论

评论列表(0)

  1. 暂无评论