滚动TreeView滚动条到被选中节点

选择TreeView节点,页面回送刷新后,滚动条自动回到TreeView顶部,而不是被选中节点处,使节点在Treeview可视区域可见,可以利用scrollIntoView方法使TreeView中页面刷新后自动定位到被选择节点处,使被选择节点可见,方法如下:

<!--Treeview定义页面-->
<body onload="ScrollToSelectNode();">
    。。。。。。
    <div id="divScroll" style="overflow-y:auto;overflow-x:auto;WIDTH: 250px;height:400px;">
        <asp:TreeView ID="tvAssetKind" runat="server" Width="100%" ExpandDepth="1">
        </asp:TreeView>
    </div>
    。。。。。。
</body>

<!--JS处理方法-->
<script language="javascript" type="text/javascript">          
    //滚动到选择节点
    function ScrollToSelectNode()
    {
        try
        {
            var elem = document.getElementById('tvAssetKind_SelectedNode');
            if(elem != null )
            {
                var node = document.getElementById(elem.value);
                if(node != null)
                {
                    
//滚动被选择节点到TreeView顶部
                    node.scrollIntoView();
                    
                    
//使被选择节点距离TreeView顶部10,使被选择节点可见
                    document.getElementById("divScroll").scrollLeft = 0;
                    document.getElementById("divScroll").scrollTop -= 10;
                }
            }
        }
        catch(oException)
        {
        }
    }        
</script>

scrollTop、scrollLeft、scrollWidth、scrollHeight