控制JAVASCRIPT中的模态窗体的相对位置
<script language=javascript>
function openwindow(RightMove,ButtomMove)
{
ActiveLeft = 0;
ActiveTop = 0;
//对话框的宽度
//对话框的高度
dialogWidth = 400;
dialogHeight = 300;
//最多宽度
//最多高度
MaxWidth = screen.availWidth;
MaxHeight = screen.availHeight;
//中心点位置
CenterWidth = MaxWidth/2;
CenterHeight = MaxHeight/2;
ActiveTop = CenterHeight - dialogHeight /2
ActiveLeft = CenterWidth - dialogWidth /2
//设置显示顶部的位置
if(ActiveTop + ButtomMove +dialogHeight > MaxHeight)
{
ActiveTop = MaxHeight - dialogWidth;
if(ActiveTop <0)
{
ActiveTop = 0;
}
}
else
{
ActiveTop = ActiveTop + ButtomMove;
}
//设置显示左边的位置
if(ActiveLeft + RightMove +dialogWidth > MaxWidth)
{
ActiveLeft = MaxWidth - dialogWidth;
if(ActiveLeft <0)
{
ActiveLeft = 0;
}
}
else
{
ActiveLeft = ActiveLeft + RightMove;
}
showModalDialog('WebForm6.aspx',window,'dialogWidth:'+dialogWidth+'px;dialogHeight:'+dialogHeight+'px;dialogLeft:'+ActiveLeft+'px;dialogTop:'+ActiveTop+'px;center:yes;help:yes;resizable:yes;status:yes')
return true;
}
正中间:
openwindow(0,0)
右下方:
openwindow(100,100)
右上方:
openwindow(100,-100)
其他的自己想。
</script>