使用window.open(),如下所示
window.open("NewWin.aspx","NewWin","resizable=no,status=yes,toolbar=no,menubar=no,location=no,height=350,width=500,top=100,left=150");
关于分辨率,你可以用window.screen.width判断是1024还是800,然后计算设置相应的top和left吧
window.open("NewWin.aspx","NewWin","resizable=no,status=yes,toolbar=no,menubar=no,location=no,height=350,width=500,top=100,left=150");
关于分辨率,你可以用window.screen.width判断是1024还是800,然后计算设置相应的top和left吧
我在想能不能用showModalDialog("login.aspx",window,"center:yes;"),
它可以自动居中。然后在login.aspx中关闭调用showModalDialog()的那个窗口,你看可不可以?
你还可以在打开的页面里用window.moveTo和window.resizeTo设置相应的大小和位置
showModalDialog(),顾名思意,模式窗口,只能交互后自己关闭
<BODY onload="window.open('http://www.csdn.net','','width=500,height=300,resize=1,left=262,top=234')">
<script>
alert((screen.width-500)/2+"\n"+(screen.height-300)/2)
</script>
其中left=262是通过screen.width-打开窗口的width后除以2得出
top=234同样道理,所以你可以保证任何分辨率下打开的窗口都是居中的