focus center window

liunx

Guest
i must be dumb... ive been trying for weeks to get my flash site to open up in a new window (easy) and have the window centered in the viewers screen (impossable!) i got a little help with it, but the script i put in the head of the HTML doc like it said and i just didnt work. im probably doing it wrong, i dunno. can anyone please help me out?<!--content-->uhh code would be good!!<!--content-->ok here's the script, ill just post it here so i dont have to register at 100 different forums, so ok:<br />
<br />
<br />
<br />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><br />
<html><br />
<head><br />
<script language="JavaScript" type="text/JavaScript"><br />
function NewWindow(u,n,w,h,f,p,x,y){varws=window.screen?1:0,m=Math,C='center',R='random',M='custom',sw=screen.availWidth,sh=screen.availHei ght,T=(p==C&&ws)?(sh-h)/2:(p==R&&ws)?(m.floor(m.random()*(sh-h))):(p==M)?y:100,L=(p==C&&ws)?(sw-w)/2:(p==R&&ws)?(m.floor(m.random()*(sw-w))):(p==M)?x:100,s='width='+w+',height='+h+',top='+T+',left='+L;s+=(!f||f=='')?'':','+f;win=window. open(u,n,s);if(win.focus)win.focus();}<br />
// --><br />
</script> <br />
<title>intrepid design ver 3</title><br />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><br />
</head><br />
<br />
<body><br />
<table width="75" border="0" align="left" cellpadding="0" id="intrepid design flash"><br />
<tr><br />
<td><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://Download <!--more-->.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="700" height="400" align="top"><br />
<param name="movie" value="id3.swf"><br />
<param name="quality" value="high"><br />
<param name="LOOP" value="false"><br />
<embed src=http://www.htmlforums.com/archive/index.php/"id3.swf" width="700" height="400" loop="false" align="top" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></object></td><br />
</tr><br />
</table><br />
</body><br />
</html><!--content-->do this<br />
<br />
<head><br />
<script language="JavaScript" type="text/JavaScript"><br />
function NewWindow(u,n,w,h,f,p,x,y){<br />
if(window.screen){ <br />
var ah=screen.availHeight-30; <br />
var aw=screen.availWidth-10; <br />
var xc=(aw-w)/2; <br />
var yc=(ah-h)/2; <br />
Str =",left="+xc+",screenX="+xc; <br />
Str +=",top="+yc+",screenY="+yc; <br />
Str += ",width="+w+",height="+h; <br />
} <br />
<br />
win=window.open(u,n,Str);<br />
if(win.focus)win.focus();}<br />
// --><br />
</script> <br />
<br />
and nobody said to register at 100 forums. we can't help unless we see the code you have first.<!--content-->yaeh i tried it out and it dosnt seem to work. let me just make sure im doing it right. that code goes in the head of the page that im trying to get centered. do i have to do anything with the button on the splash page that is before the "centered" page? (besides onClick open browser window) i dunno, i dont understand why its not working....<br />
<br />
<br />
ps i debugged it in IE and got this<br />
<br />
Error 1026 expected ";"<br />
The specified operator was expected<br />
<br />
If(window.screen){ <---- this was the line that had the error<!--content-->well you have to call that function, which should be the same as your old one. <br />
<br />
try it again as I made a change to it. I had "If" which should have been "if"<!--content-->ok well i put the revised script in there and still nothing (call function is something that i am unfamilure with, is it critical?)<!--content-->well yeah, how are you doing it? you have to call that function in order to open the new window. you said the window was opening normally so I figured you were calling it ok.<!--content-->the window that i want centered is opening from another page before it. in dreamweaver i made a splash page that upon clicking the enter button (onClick Open Brower Window) the page i want centered appears. now i set size, scrollbar, ect restrictions on the new page. ie. it can only be 700 x 400 with no scrollbars, resize handles and address bars. could this somehow be overriding the script to center the new window??<!--content-->ok so in your flash page .fla you made it open a new window? where is the enter button? in the flash or on the html page?<!--content-->no the first page is HTML only,no flash. the second page that is opened from the HTML page is flash. im trying to get the HTML page to open the flash page center screen.<!--content-->the javascript that is here has to go in the regular html page and then in your popup you load the flash. so that means you have 2 pages. your html page with the javascript in it, then the popup page with the flash in it. the one you posted will not work as that is the page that gets popuped up.<br />
<br />
unless I am overly confused.<!--content-->hahaha i think im getting overly confused too. thanks for all ur help btw. well ill try placing the script into the first page. (the second page is also HTML just with flash embeded, there are no links or anything, just a dreamweaver doc with one table and the flash site plopped in.)<!--content-->yup that is correct. the very fisrt page should be something like this<br />
<br />
index.html<br />
<br />
<html><br />
<head><br />
<script language="JavaScript" type="text/JavaScript"><br />
function NewWindow(u,n,w,h,f,p,x,y){<br />
if(window.screen){ <br />
var ah=screen.availHeight-30; <br />
var aw=screen.availWidth-10; <br />
var xc=(aw-w)/2; <br />
var yc=(ah-h)/2; <br />
Str =",left="+xc+",screenX="+xc; <br />
Str +=",top="+yc+",screenY="+yc; <br />
Str += ",width="+w+",height="+h; <br />
} <br />
<br />
win=window.open(u,n,Str);<br />
if(win.focus)win.focus();}<br />
// --><br />
</script> <br />
</head><br />
<body><br />
<a href=http://www.htmlforums.com/archive/index.php/"#" onclick="NewWindow('flash.html','',700,400,'','','','')">enter</a><br />
</body><br />
</html><br />
<br />
<br />
there is extra variables in there so you may want to take the unused ones out.<br />
<br />
now when you click on that it will open the flash page centered.<!--content-->OMG! it works!!!!! thanks a lot, i can finally put this up now. it should be up in a day or two so come and visit at <!-- w --><a class="postlink" href="http://www.danwulfing.com">www.danwulfing.com</a><!-- w --> . thanks again for all the help!<!--content-->
 
Back
Top