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已经设定了窗口大小
所以 点击出来的效果是 窗口由大变小 但是速度很快 效果也不好看所以 现在希望窗口可以慢慢的变化 有动画的效果
控制窗口大小 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已经设定了窗口大小
所以 点击出来的效果是 窗口由大变小 但是速度很快 效果也不好看所以 现在希望窗口可以慢慢的变化 有动画的效果
{
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);
}没有效果哎~
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);
}
如果你其他代码没问题的话,这个就该没有问题了
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加不加 效果是一样的 代码哪里不对啊???急死偶了
没搞错吧?不加setTimeOut这一句,你那个函数就只执行一遍,能有毛的动画效果啊?
setTimeout(function(){dlgAutoResize(tblID);}, 100);就是这一句进行的递归调用才能产生动画效果,如果没有动画效果只能说你的其他代码是有问题的,不能实现要的效果。
就是窗口都是非常迅速的由大变小偶想要的效果是 窗口由大慢慢的变小“如果没有动画效果只能说你的其他代码是有问题的,不能实现要的效果。”
偶其他的代码 在不+setTimeout 得到的效果 都是 偶想要的
如果有问题 大概是哪个方向的呢
变化太快是你每次加的太多
width = eval(width + 52);
height = eval(height + 82); 每次加这么多能不块么?
还有setTimeOut的延时,设大点也自然就慢些
求助!!!!
{
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)));
}
}
{
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)));
}
}
这个的效果是 窗口没有变化 是原始值 this.ShowModalDialog(url, 500, 500, "");
但窗口内的table不断的变大
怎么写 可以改换成窗口根据实际table的大小 逐步转换窗口的大小
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);
}