PDA

View Full Version : Centering a Popup Window


rissac
01-04-2002, 05:11 PM
I'm using a button on my splash page that will pop up my main internet site page at a specific size. The problem is I can't get the movie which is a Flash movie to be centered on the HTML page. Below is the script I'm using to call the HTML page.

Java Script:

<script language="JavaScript">
<!--
function NewWin(URL, WinName) {
myNewWin=open(URL, WinName, 'toolbar=no,location=no,directories=no,status=yes,scrollbars=no,resizable=no,width=900,height=500'); }

Button Action

<a href="javascript:NewWin('http://www.sergeeustache.com/FlashSite.html')"><img src="Images/Enter_Button.gif" width="121" height="28" align="left" hspace="180" border="0"></a></td>


You will be able to see what I talking about if you go to my site at http://www.sergeeustache.com
Thanks

scoutt
01-04-2002, 07:21 PM
here is a script that centers a popup

// open a popup centered on the screen
Function centerWindow(popupUrl, popupWidth, popupHeight){
If(window.screen){
var ah=screen.availHeight-30;
var aw=screen.availWidth-10;
var xc=(aw-popupWidth)/2;
var yc=(ah-popupHeight)/2;
Str =",left="+xc+",screenX="+xc;
Str +=",top="+yc+",screenY="+yc;
Str += ",width="+popupWidth+",height="+popupHeight;
}
previewWindow = window.Open(popupUrl,"","toolbar=0,location=0,menubar=0,scrollbars=1,status=0,resizable=1,width="+popupWidth+",height="+popupHeight+""+Str);
previewWindow.focus();
}

'Call it Like this
<a href="popupUrl" target="previewWindow" onclick="centerWindow('popupUrl', popupWidth, popupHeight);return false;">Open It</a>

cessandra
01-04-2002, 07:21 PM
i think you just need to make the pop-up a little bit wider. as far as i know, it's going to have a little space on the left hand side no matter what you do.

_mrkite
01-04-2002, 08:36 PM
At first I thought you meant the pop-up wasn't centered; but maybe you were referring to the Flash movie not butting up against the window margins. Try this in the popup HTML:

<body marginwidth="0" marginheight="0" leftmargin="0" topmargin="0">