zoukankan      html  css  js  c++  java
  • 自动调整窗口高度,消除模态窗口的滚动条

              因为项目里面经常需要用到window.showModalDialog,这时候打开一个页面的时候给窗口指定一个高度比如500px,有时候页面的内容经常变化,这时候因为页面内容的高度超过了打开窗口的高度,就需要经常去修改window.showModalDialog里面的参数,相当的麻烦 ,于是就想写一个通用的函数自动调整打开页面的高度。
           
     window.onload=ResizeWindow;
     function ResizeWindow()
    {   
        var tables
    =document.getElementsByTagName('table')    
        tables[tables.length
    -1].scrollIntoView(false);
        var scrollTop
    =document.documentElement.scrollTop;
        
    if(scrollTop==0)
        {
            
    return;
        }
        
    else    
        {
            var height
    =document.documentElement.currentStyle.height;
            height
    =parseInt(height)+scrollTop+20;
            
    if(height>800)
            {
                
    return;       
            }
            
    else
            {        
                window.external.dialogHeight
    =height+"px";    
            }
        }
    }

            以上代码在模态窗口IE6.0中调试通过。因为firefox好象不支持模态窗口,所以就没必要在firefox下测试了。以上代码仅在模态窗口中适用。
  • 相关阅读:
    protobufer安装
    flume sink processor
    flume 参考
    uniq 和 sort -u的不同
    XtraInputBox-How to set the XtraInputBox as password input?
    原型模式
    C#-IEditableObject Interface
    gridControl-The BindingSource.AddingNew event does not fire until I begin typing into the new row
    C#中Invoke 和 BeginInvoke 的区别
    C#启动时全屏显示窗体...
  • 原文地址:https://www.cnblogs.com/bingxuefly/p/638989.html
Copyright © 2011-2022 走看看