Log in

View Full Version : Center Popup Window without Javascript?



Cheng
08-31-2006, 04:17 PM
Hi.

I got this program FormArtist which provides a link to open the form in a popup window.
Bu the window is not a 100% centered on the screen.
Is it possible to center this popup window without javascript?
Here wghat the link looks like:

<a href="#" onclick="window.open('http://www.arbitrade.org/Form/arbitrade.htm', 'arbitrade', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=690,height=530');">Contact Form</a>
I think it is possible as someone showed me before how to open a window centered without javascript but I don't have that piese of code anymore.
Maybe someone here can show me what to change in this code here to center the popup.

Thanks inadvance.

Cheng

mwinter
08-31-2006, 04:53 PM
I got this program FormArtist which provides a link to open the form in a popup window.

You shouldn't use a pop-up window, especially for a contact form (as this would appear to be). Pop-ups are unreliable, have been for a while, and are becoming less and less viable. How do you expect someone to contact you if the pop-up is blocked, or, with the code you posted, with scripting disabled?



Bu the window is not a 100% centered on the screen.

Putting it there reliably isn't very feasible; most solutions you'll find on the Web don't consider multiple monitors.



Is it possible to center this popup window without javascript?

No, not at all.



<a href="#" onclick="window.open('http://www.arbitrade.org/Form/arbitrade.htm', 'arbitrade', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=690,height=530');">Contact Form</a>

At least rewrite that to:



<a href="http://www.arbitrade.org/Form/arbitrade.htm" target="arbitrade"
onclick="return !window.open(this.href, this.target, 'scrollbars,resizable,width=690,height=530');"
>Contact Form</a>

A pop-up should always have scrollbars enabled and be resizable. If you gave it the right size, neither will matter. However, if you didn't, the content will be clipped and inaccessible.



Maybe someone here can show me what to change in this code here to center the popup.

If you must use pop-ups, let the window manager handle positioning.

Mike

Cheng
08-31-2006, 06:37 PM
Hi Mike.

Thanks for the advise.
What do you meam by:

If you must use pop-ups, let the window manager handle positioning.
Thanks again.

Cheng

mwinter
08-31-2006, 09:00 PM
What do you meam by:


If you must use pop-ups, let the window manager handle positioning.


The window manager controls window positioning, amongst other things. It will know the preferred monitor in multi-monitor systems, where the last window created was positioned, how to cascade windows, and so on. Leave it to make the decision.

Mike