JS根据高度自动添加滚动条

<script>
    $(document).ready(function(){
        var height=$(window).height()-50;
        var o = document.getElementById("view");
        var h = o.offsetHeight; //高度
        if(h > height){
            o.style.overflow='auto';
            o.style.height=height+'px';
        }
    });
</script>

 

posted @ 2017-09-19 17:19  幻月无痕  阅读(1084)  评论(0编辑  收藏  举报