Main.aspx   
控制窗口大小  this.ShowModalDialog(url, 500, 500, "");   弹出Edit.aspxEdit.aspx   
<body onload="dlgAutoResize('tblMain');">
JSfunction dlgAutoResize(tblID)

  var width = document.all[tblID].offsetWidth;     
  var height = document.all[tblID].offsetHeight;  
  width  = eval(width + 52); 
  height = eval(height + 82); 
  if (width > screen.width)
  {
    width = screen.width;
  } 
  if (height > screen.height)
  {
    height = screen.height; 
  }
  }
由于Edit.aspx页面自动调整了窗口   但是Main.aspx已经设定了窗口大小
所以 点击出来的效果是 窗口由大变小   但是速度很快 效果也不好看所以 现在希望窗口可以慢慢的变化 有动画的效果

解决方案 »

  1.   

    用setTimeout 让高度慢慢变化到需要的宽度和高度就行了
      

  2.   

    function dlgAutoResize(tblID)

      var width = document.all[tblID].offsetWidth;     
      var height = document.all[tblID].offsetHeight;  
      width  = eval(width + 52); 
      height = eval(height + 82); 
      if (width > screen.width)
      {
        width = screen.width;
      } 
      if (height > screen.height)
      {
        height = screen.height; 
      }
    setTimeout("dlgAutoResize(tblID)", 5000);
      }没有效果哎~
      

  3.   

    你参数传递方式有问题!
    setTimeout("dlgAutoResize("+tblID+")", 5000);
    递归又没有出口条件,会一直执行。
    function dlgAutoResize(tblID)

      var width = document.all[tblID].offsetWidth;     
      var height = document.all[tblID].offsetHeight;  
      width  = eval(width + 52); 
      height = eval(height + 82); 
      if (width > screen.width)
      {
        width = screen.width;
    return;
      } 
      if (height > screen.height)
      {
        height = screen.height; 
    return;
      }
    setTimeout(function(){dlgAutoResize(tblID);}, 50);
      }
    如果你其他代码没问题的话,这个就该没有问题了
      

  4.   


    function dlgAutoResize(tblID)

      var width = document.all[tblID].offsetWidth;     
      var height = document.all[tblID].offsetHeight;    width  = eval(width + 52); 
      height = eval(height + 82);   if (width > screen.width)
      {
        width = screen.width;
      } 
      if (height > screen.height)
      {
        height = screen.height; 
      }
      if(window.dialogWidth != width+"px" && window.dialogHeight != height+"px")
      {
        window.dialogTop = (screen.height-height)/2+"px";
        window.dialogLeft = (screen.width-width)/2+"px";
        window.dialogHeight = height+"px";
        window.dialogWidth = width+"px"; 
      }
       setTimeout(function(){dlgAutoResize(tblID);}, 100);
    }
    Main.aspx  this.ShowModalDialog(url, 480, 600, ""); 初始值
    Edit.aspx  <body onload="dlgAutoResize('tblMain');"> setTimeout加不加 效果是一样的   代码哪里不对啊???急死偶了
      

  5.   

    是不是应该再一个function ??
      

  6.   

    你去百度一下setTimeout的用法吧
      

  7.   

    setTimeout加不加 效果是一样的?
    没搞错吧?不加setTimeOut这一句,你那个函数就只执行一遍,能有毛的动画效果啊?
    setTimeout(function(){dlgAutoResize(tblID);}, 100);就是这一句进行的递归调用才能产生动画效果,如果没有动画效果只能说你的其他代码是有问题的,不能实现要的效果。
      

  8.   

    3个if(return;)最下面都+了偶说的setTimeout 加不加 效果都一样 
    就是窗口都是非常迅速的由大变小偶想要的效果是  窗口由大慢慢的变小“如果没有动画效果只能说你的其他代码是有问题的,不能实现要的效果。”
    偶其他的代码 在不+setTimeout   得到的效果 都是 偶想要的
    如果有问题 大概是哪个方向的呢
      

  9.   

    由大变小,我看代码似乎是由小变大哦
    变化太快是你每次加的太多
      width  = eval(width + 52); 
      height = eval(height + 82); 每次加这么多能不块么?
    还有setTimeOut的延时,设大点也自然就慢些
      

  10.   

    setTimeOut 用了    但是效果 抖的太厉害了  有么有 其他的方法啊
    求助!!!!
      

  11.   

        function dlgAutoResize(tblID)
        {
            resize=setInterval(Func, 1000);
        }    function Func()
        { 
          var width = document.all['tblMain'].width;   
          var height = document.all['tblMain'].height; 
          if(width < screen.width)
          {
           if(width=="") width=document.all['tblMain'].offsetWidth;
           document.all['tblMain'].width=eval(parseInt(width*(1+0.1)));
          }
          if(height < screen.height)
          {
           if(height=="") height=document.all['tblMain'].offsetHeight;
           document.all['tblMain'].height=eval(parseInt(height*(1+0.1)));
          }
        }   
      

  12.   

    多写了resize,用下面这个    function dlgAutoResize(tblID)
        {
            setInterval(Func, 1000);
        }    function Func()
        { 
          var width = document.all['tblMain'].width;   
          var height = document.all['tblMain'].height; 
          if(width < screen.width)
          {
           if(width=="") width=document.all['tblMain'].offsetWidth;
           document.all['tblMain'].width=eval(parseInt(width*(1+0.1)));
          }
          if(height < screen.height)
          {
           if(height=="") height=document.all['tblMain'].offsetHeight;
           document.all['tblMain'].height=eval(parseInt(height*(1+0.1)));
          }
        }   
      

  13.   


    这个的效果是  窗口没有变化 是原始值 this.ShowModalDialog(url, 500, 500, ""); 
    但窗口内的table不断的变大   
    怎么写 可以改换成窗口根据实际table的大小 逐步转换窗口的大小
      

  14.   


    function dlgAutoResize(tblID,autowidth,autoheight)

      var width = document.all[tblID].offsetWidth;
      var height = document.all[tblID].offsetHeight;
      
      width  = eval(width + 52); 
      height = eval(height + 82);
      
      if(autowidth=="" || autoheight=="")
      {
         autowidth = screen.width;
         autoheight = screen.height; 
      }  if(autowidth > width)
      {
         autowidth = autowidth-50;
      }  if(autoheight > height)
      {
         autoheight = autoheight-50;
      }  if (width > screen.width)
      {
        width = screen.width;
      } 
      if (height > screen.height)
      {
        height = screen.height; 
      }  if(window.dialogWidth != width+"px" && window.dialogHeight != height+"px")
      {
        window.dialogLeft = (screen.width-width)/2+"px";
        window.dialogTop = (screen.height-height)/2+"px";
        window.dialogWidth = autowidth+"px"; 
        window.dialogHeight = autoheight+"px"; 
      }
      setTimeout(function(){dlgAutoResize(tblID,autowidth,autoheight);},1);
    }