Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you center from a form?

Status
Not open for further replies.

Corneliu

Technical User
Sep 16, 2002
141
US
How do I center the new popup window on the screen? I seen many posts on this, but Sorry I am not good in Javascript and dont really know how to make changes this code. I use this code to automatically link the form's dropdown item to a new page.
Here it is:

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!-- Begin
function formHandler2(form) {
var windowprops = &quot;height=730,width=1018,location=no,&quot;
+ &quot;scrollbars=no,menubars=no,toolbars=no,resizable=no&quot;;

var URL = Logon.site.options[Logon.site.selectedIndex].value;
popup = window.open(URL,&quot;MenuPopup&quot;,windowprops);
}
// End -->
</script>

Than I have the form with this on it:
onChange=&quot;formHandler2(this.form)&quot;

Everything works great, just that the new window comes up on the bottom-right of the screen.
I wanted the window to just center on the screen.

Anyone can help me with this please?
 
<script>
if (document.screen){
wHeight = screen.height
wWidth = screen.width
}
else{
wHeigth = 480
wWidth = 640
}

popHeight = 300
popWidth = 400

wTop = (wHeigth - popHeight) / 2
wLeft = (wWidth - popWidth) / 2

window.open(&quot;newPage.htm&quot;,&quot;newWin&quot;,&quot;height=&quot; + popHeight + &quot;,width=&quot; + popWidth + &quot;,top=&quot; + wTop + &quot;,left=&quot; + wLeft)

</script>

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rich Cook
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top