Main.aspx
控制窗口大小 this.ShowModalDialog(url, 500, 500, ""); 弹出Edit.aspx
Edit.aspx
<body onload="dlgAutoResize('tblMain');">
JS
- JScript code
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; } }
由于Edit.aspx页面自动调整了窗口 但是Main.aspx已经设定了窗口大小
所以 点击出来的效果是 窗口由大变小 但是速度很快 效果也不好看
所以 现在希望窗口可以慢慢的变化 有动画的效果
------解决方案--------------------
用setTimeout 让高度慢慢变化到需要的宽度和高度就行了
------解决方案--------------------
你参数传递方式有问题!
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);
}
如果你其他代码没问题的话,这个就该没有问题了
------解决方案--------------------
你去百度一下setTimeout的用法吧
------解决方案--------------------
setTimeout加不加 效果是一样的?
没搞错吧?不加setTimeOut这一句,你那个函数就只执行一遍,能有毛的动画效果啊?
setTimeout(function(){dlgAutoResize(tblID);}, 100);就是这一句进行的递归调用才能产生动画效果,如果没有动画效果只能说你的其他代码是有问题的,不能实现要的效果。
------解决方案--------------------
- JScript code
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))); } }
------解决方案--------------------
多写了resize,用下面这个
- JScript code
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))); } }
------解决方案--------------------
如需要阅读该回复,请登录或注册CSDN!