请看下列脚本:<script language="javascript">function aa(){var aa=open(" m","aa","scrollbars=1,resizable=1,width=568,height=490,top=20,left=102");}</script>以上表示的新窗口在800×600屏幕中绝对左右居中。但在1024×768屏幕中此窗口就偏到左上方了。如何编写脚本,使同一窗口无论在800×600、或1024×768、或其他分辨率的屏幕中都能出现在绝对左右居中的位置?(我指的是已设定大小的窗口,例如以上width=568,height=490这一设定不变。)

热心网友

下面框中为脚本显示区function openwindow( url, winName, width, height) {xposition=0; yposition=0;if ((parseInt(navigator。appVersion) = 4 )){xposition = (screen。width - width) / 2;yposition = (screen。height - height) / 2;}theproperty= "width=" + width + "," + "height=" + height + "," + "location=0," + "menubar=0,"+ "resizable=1,"+ "scrollbars=0,"+ "status=0," + "titlebar=0,"+ "toolbar=0,"+ "hotkeys=0,"+ "screenx=" + xposition + "," //仅适用于Netscape+ "screeny=" + yposition + "," //仅适用于Netscape+ "left=" + xposition + "," //IE+ "top=" + yposition; //IE window。open( url,winName,theproperty );}//--打开窗口。

热心网友

有一个默认对象screen,你可以取到显示的分辨率,比如800×600,那么screen.width=800;screen.height=600.你可以通过计算确定新窗口的左顶点位置,也即上面的top、left值。比如:left=(screen.width-568)/2