...

View Full Version : centering a browser window



nectar
07-09-2003, 12:41 PM
Could someone do me the favour of looking at this script, played about with it, but no luck, cant get it to center and have the right size window...
This is called from flash
Thanks much appreciated

<SCRIPT LANGUAGE="JavaScript">
<!--
var newWin;
function openWindow1() {
var w = 760;
var h = 520;
var x = (screen.width-w)/2;
var y = (screen.height-h)/2;
var settings = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+w+',he ight='+h+',left='+x+',top='+y+'",
newWin=window.open("home.htm","home",settings);
newWin.focus()
}
-->
</script>

wickford
07-09-2003, 01:05 PM
There were some small mistakes in the settings variable. Try using this script (the typos were in the settings variable)



var newWin;
function openWindow1() {
var w = 760;
var h = 520;
var x = (screen.width-w)/2;
var y = (screen.height-h)/2;
var settings="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width="+w+",height="+h+",left="+x+",top="+y;
newWin=window.open("home.htm","home",settings);
newWin.focus()
}

nectar
07-09-2003, 02:28 PM
Thanks Wickford for your correction
It works fine now.

Kor
07-09-2003, 02:36 PM
maybe is better to use
screen.availHeight and screen.availWidth

because you don't know if user has small/large icons with text/notext labels on browsers toolbar, or if he uses hidden/visible bottom/up/left/right Windows Toolbar...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum