-
I have an html page that resizes to whatever the users screen rez is. I then have a "launch site button" that launches the flash movie in a constrained window..... all works, but the window always pops up in the upper left corner of the screen. Is there a way to always have it centered on the screen, based on the current size of the background window (it changes based on the screen rez) all help would be greatly appreciated..... -Fred
-
Welcome to Flashkit, generalfred!
There's probably at least one thread on this subject, but this is what I use:
In your intial HTML page:
<script language="JavaScript">
<!--
function openNewWindow(URL,winName,features){
var xPos = (screen.width-700)/2;
var yPos = (screen.height-400)/2;
newWin=window.open(URL,winName,features);
newWin.moveTo(xPos,yPos);
newWin.focus();
}
-->
</script>
In this case, a Flash button to launch the window:
on (release) {
getURL ("javascript:openNewWindow ('yourfile.html','wp','width=700,height=400,scroll bars=no')");
}
Note: The window dimensions are defined in the getURL command.
Enjoy!
-
-
HELP!!! Over here!!!
for the life of me, I can't get this to work! I've searched EVERYWHERE to find a solution.... no avail! I just need the main HTML page to maximise (win/mac), and after clicking an html link, pop open window in the center of the screen... please help, before I'm bald from pulling out my hair!!! : )
-
Hi there,
I'm also trying to get a pop-up window to centre on screen. I am a complete novice and cannot hand code html so could you please walk me through step by step on where exactly to put this script, as the code appears on my page when I type it in. Please help. I'm already bald!
-
Try this:
Code:
<html>
<head>
<script language="javascript">
<!--
//
//change popWidth and popHeight as appropriate
//
var initialContent = "whatever.html";
var popWidth = 400;
var popHeight = 300;
//
//no need to change any script below here
//
var popX = (screen.availWidth/2)-(popWidth/2);
var popY = (screen.availHeight/2)-(popHeight/2);
var popped = null;
var winAtts = null;
var oldBrowser = false;
//
function popOne(){
if(!window.resizeBy){
oldBrowser = true;
}
winAtts = getWinAtts();
popped = window.open(initialContent,'noname',winAtts);
}
//
function getWinAtts(){
winAtts = "width=" + popWidth + ",height=" + popHeight;
//used for IE
winAtts += ",left=" + popX + ",top=" + popY;
//used for netscape
winAtts += ",screenX=" + popX + ",screenY=" + popY;
if (!document.all) {
winAtts += ",resizable=1"
}
return winAtts;
}
//
function closePopped(){
if(popped != null){
if(!popped.closed){
popped.close();
}
}
}
//
popOne();
//-->
</script>
<body>
</body>
</html>
-