Click to See Complete Forum and Search --> : Help im stuck and cant work this out....


mentaleruptions
06-20-2003, 01:20 AM
Hey all ive been trying to work out how to get this bit of script to open a center popup so that no matter what screen res u have its centerd. The script is in a .js file called by a bit of code in the html file.
At the moment i just have it so its done manualy and its setup for 1024 x 768 but i need it to auto detect and cant get anything ive found searching here to work.
Heres the code im trying to work out in the .js file:


function openwindow()
{
var w = window.open("main.html","testWindow","top=171,left=127,width=770,height=425");
top.location.href = location.href;
opener = self;
self.close();
}


As u can see its only got the size and position manualy there but i need it to center as i said above.
Heres the bit of code that calls it from ur html file put between the head tags:


<script type="text/javascript" src="window.js"></script>
<script>
openwindow();
</script>


I sure hope someone can help me out here :). Ive been trying all sorts of stuff for hours now and just no lug.
I guess being a newbie is winning on this one :).

All help would be great.

Thanks in advance, Mental

Khalid Ali
06-20-2003, 02:11 AM
search the forum,this question has been answered a tonne of times

Gopinath
06-20-2003, 02:12 AM
This is the pop up window
<html>
<head>
<LINK title=APlusFactor href="common/Educ_style.css" type=text/css rel=stylesheet>
<script language="javascript">
var skipcycle = false

function fcsOnMe(){
if (!skipcycle){
window.focus();
}
mytimer = setTimeout('fcsOnMe()', 500);
}
</script>
</HEAD>
<BODY onload=fcsOnMe()>
<TABLE WIDTH=100% align='center' BORDER=0 CELLSPACING=1 CELLPADDING=0 class='cellborder' class=gridform>
<TR align='center'>
<TH align=center colspan=2 class='tablehead'> Color Legend</TH>
</TR>
<TR class='firstcolor'>
<TD width='5%' bgcolor='#FFB59E'>&nbsp;</TD>
<TD width='45%' class='columnvalue'> Submitted and Waiting for Acceptance </TD>
</TR>
<TR class='firstcolor'>
<TD width='5%' bgcolor='#C8C8FF'>&nbsp;</TD>
<TD width='45%' class='columnvalue'>Late Submission and Waiting for Acceptance</TD>
</TR>
<TR class='firstcolor'>
<TD width='5%' bgcolor='#C800C8'>&nbsp;</TD>
<TD width='45%' class='columnvalue'>Accepted and Waiting for Grading</TD>
</TR>
<TR class='firstcolor'>
<TD width='5%' bgcolor='#E1C864'>&nbsp;</TD>
<TD width='45%' class='columnvalue'>Refused</TD>
</TR>
<TR class='firstcolor'>
<TD width='5%' bgcolor='#969619'>&nbsp;</TD>
<TD width='45%' class='columnvalue'>Resubmitted and Waiting for Acceptance</TD>
</TR>
<TR class='firstcolor'>
<TD width='5%' bgcolor='#AA96CA'>&nbsp;</TD>
<TD width='45%' class='columnvalue'> Graded and Waiting for Approval </TD>
</TR>
<TR class='firstcolor'>
<TD width='5%' bgcolor='#99AAFF'>&nbsp;</TD>
<TD width='45%' class='columnvalue'> Graded and Approved </TD>
</TR>
</TABLE>

</BODY>
</HTML>

------------------

Calling window

<script language='javascript'>
var skipcycle=false
strBrowserName=navigator.appName
var bln_Brotype=false
if(strBrowserName=="Netscape")
{
bln_Brotype=true
}
function funcColorcode()
{

if(bln_Brotype==false)
{
window.showModalDialog("educ_colorcode.htm","colorcode","dialogWidth=300px;dialogHeight=225px;dialogTop=300px;dialogleft=400px")
}
else
{
window.open ("educ_colorcode.htm","ModalChild","scrollbars=1,width=300,height=225,top=300,left=400")
}
return false
}
function funcGradeScale()
{

if(bln_Brotype==false)
{
window.showModalDialog("Gradescale.htm","colorcode","dialogWidth=500px;dialogHeight=340px;dialogTop=150px;dialogleft=200px")
}
else
{
window.open ("Gradescale.htm","ModalChild","scrollbars=1,width=500,height=340,top=150,left=200")
}
return false

}
</script>

mentaleruptions
06-20-2003, 02:42 AM
Originally posted by Khalid Ali
search the forum,this question has been answered a tonne of times

I did a search and the closest thing i could come up with was this:

http://forums.webdeveloper.com/showthread.php?s=&threadid=10842&highlight=center

I tried to use that method but it just wouldnt work. So this is why i posted. I spend alot of time on other boards and never post unless i search believe me but i really couldnt find anything of use.
Im basicly new to javascript and was hoping for some more pointers than just search the forums ;) .
So any other ideas out there for a newbie ??

Thanks once again, Mental

JHL
06-20-2003, 03:55 AM
var w = window.open("test.html","testWindow","top=" + (screen.availHeight - 425) / 2 + ",left= " + (screen.availWidth-770) / 2 + ",width=770,height=425");

mentaleruptions
06-20-2003, 04:07 AM
Originally posted by JHL
var w = window.open("test.html","testWindow","top=" + (screen.availHeight - 425) / 2 + ",left= " + (screen.availWidth-770) / 2 + ",width=770,height=425");

Hey JHL thanks a million :) works the way it should do now :).
I had it sort of the same way but i had the possition in there manualy still so ive learnt something now :D .

I owe u one, Mental