jstree链接在IE8中不工作

jstree link are not working in IE8

本文关键字:工作 IE8 链接 jstree      更新时间:2023-09-26

我使用以下代码:

        <html>
        <head>
            <title>TODO supply a title</title>
            <meta charset="UTF-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <link rel="stylesheet" href="http://static.jstree.com/3.1.1/assets/dist/themes/default/style.min.css">
        </head>
        <body>
            <h1>HTML demo</h1>
            <div id="tree" class="demo">
                    <ul>
                        <li><a href="http://www.google.com">Google</a>
                                    <ul>
                                            <li><a href="https://mail.google.com">Gmail</a></li>
                                    </ul>
                            </li>
                           <li><a href="http://www.yahoo.com">yahoo</a>
                                    <ul>
                                            <li><a href="https://mail.yahoo.com/">yahoo mail</a></li>
                                    </ul>
                            </li>
                    </ul>
            </div>
    <script src="http://static.jstree.com/3.1.1/assets/dist/libs/jquery.js"></script>
          <script src="http://static.jstree.com/3.1.1/assets/dist/jstree.min.js"></script>
                                        <script>
                $("#tree").jstree({
                    "plugins": ["core", "themes", "html_data", "search"]
                }).on("select_node.jstree", function(e, data) {
                    document.location = data.instance.get_node(data.node, true).children('a').attr('href');
                });
                                        </script> 
    </body>
    </html>

我想在链接到jtree的节点时否定其他页面。此代码在最新版本中运行良好,但在IE8中不起作用。我该怎么做才能使它正常工作?


请在服务器上运行,当你在IE8上尝试时,你会发现问题所在。


尝试使用window.location代替document.location,因为后者在IE中是只读的:
https://developer.mozilla.org/en-US/docs/Web/API/Document/location