Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Popup window - how to center content into popup window


5:14 pm on Sep 25, 2009 (gmt 0)

New User

5+ Year Member

joined:Feb 22, 2008
posts: 13
votes: 0


Please, can someone tell me how I can (if I can), when open popup window after user click in link - new window to be with some specified dimension, but content of page which is in window to start from some line which I will define?
Do that is possible?

Thank you very much, Mladen

7:10 pm on Sept 26, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 28, 2004
votes: 0

Welcome aboard mladja04, if your pop up is an external resource or static web page, you can center content by including CSS or a link to external CSS in the head.

<style type="text/css">
#main { width: 95%;, margin: auto; }


<link rel="stylesheet" type="text/css" href="mystyle.css">

If it's written out with document.write, you can do the same:

document.write('<link rel="stylesheet" type="text/css" href="mystyle.css">');

If you mean center the pop up in the viewport, you will probably have to get the viewport's parameters (width, height, etc.) first with Javascript, then do some math to position it in the center of the viewport. No code immediately handy, but a search for Javascript Window Object should turn up some results. Note that Moz browsers and IE have different ways of getting these.

8:21 pm on Sept 26, 2009 (gmt 0)

New User

5+ Year Member

joined:Feb 22, 2008
posts: 13
votes: 0

Thank you for reply. I need to open external page in popup window and want to know do I can to specify start row in that new page.
This is code which I use (example):


1. Paste the first into the HEAD of your HTML document
2. Use the code to open the popup page on your site -->

<!-- STEP ONE: Copy this code into the HEAD of your HTML document -->


<!-- Idea by: Nic Wolfe -->
<!-- This script and many more are available free online at -->

<!-- Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=600');");
// End -->

<!-- STEP TWO: Use the following link to open the new window -->

<A HREF="javascript:popUp('http://www.mysite.com')">Open the Popup Window</A>

<!-- Script Size: 0.73 KB -->

Do it possible to I make what I need?

Thank you very much again.