Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New window position - help to adjust script

Status
Not open for further replies.

95degrees

Vendor
Mar 2, 2002
2
US
I am using a script which is as follows:

<script type="text/javascript" language="JavaScript">

var win = null;
function newWindow(mypage,myname,w,h,features) {
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/2;
if (winl < 0) winl = 0;
if (wint < 0) wint = 0;
var settings = 'height=' + h + ',';
settings += 'width=' + w + ',';
settings += 'top=' + wint + ',';
settings += 'left=' + winl + ',';
settings += features;
win = window.open(mypage,myname,settings);
win.window.focus();
}

</script>

If anyone can tell me how to define the position of the new window (X, Y coordinates) by adding to this script I would appreciate it greatly.
 
Currently, the script auto-centres the new window.

If you wish to remove this functionality, instead being able to define the left and top (x, y) positions, then this should work:

Code:
<script type="text/javascript">
<!--
	var win = null;
	function newWindow(mypage, myname, x, y, w, h, features) {
		var settings = 'left=' + x + ',';
		settings += 'top=' + y + ',';
		settings += 'height=' + h + ',';
		settings += 'width=' + w;
		if (features != '') settings += ',' + features;
		win = window.open(mypage, myname, settings);
		win.focus();
	}
//-->
</script>

Hope this helps,
Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top