Click to See Complete Forum and Search --> : anyway to center a window.open?


senn
02-09-2003, 03:19 AM
anyway to center a window.open? taking into considerations different screen resolutions, using "left=x, top=y" is not very useful.

:confused:

khalidali63
02-09-2003, 05:26 AM
Yes first get the screen resolutions of a system and then open it up at a central location on the screen.
top and left fro IE and screenX and screenY for NS

cheers

Khalid

LAwebTek
02-09-2003, 11:50 AM
I use something to this effect:

onclick="newWin=window.open('helpFrame.html','HelpWindow',
'width=500,height=275,status=no,scrollbars=yes,resizable=yes,menubar=no,toolbar=no');
newWin.moveTo(150,100); return false;"

Charles
02-09-2003, 12:39 PM
Following Khalid's lead...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<title>Window Example</title>
<script type="text/javascript">
<!--
function newWin(url, height, width) {
if (navigator.appName == 'Opera') return true;
// the following will give unacceptable results in Opera running in "Multiple Document Interface" mode
var y = 0;
var x = Math.floor((screen.width - width) / 2);
var param = 'height=' + height;
param += ',width=' + width;
param += ',height=' + height;
param += ',screenX=' + x;
param += ',left=' + x;
param += ',screenY=' + y;
param += ',top=', + y;
window.open(url, 'child', param);
return false;
}

// -->
</script>
<p><a href="http://www.w3.org/" onclick="return newWin(this.href, 400, 300)">W3C</a></p>

aunt_Lois
02-13-2003, 04:32 PM
I have been reading postings on this forum regarding the positioning of a window after being opened. I am having problems getting it to work for me and I am curious if any of you have ideas as to troubleshooting.

I have tried left=, top= and screenX=, screenY= in the windowfeatures part of the window.open javascript and have also tried winName.moveTo() without any luck.

What really confuses me is that Netscape 6 is rendering just with lef and top????

Any ideas would be appreciated much...