View Full Version : New window help

12-26-2002, 02:22 AM

I really want to be able to open up a new window when a link is clicked on.

However I would like the window to be centered [not required] and be the size of the contents within it.

Is this possible?


12-26-2002, 06:16 AM
Try this:

<!doctype html public "-//W3C//DTD HTML 4.01 Strict//EN"
<title>Center Window</title>
<script language="JavaScript1.2">
function centerWindow(mySizeX, mySizeY, url)
// Make sure the screen height and width are greater than the window's height and width
var top = (screen.height > mySizeY) ? (screen.height - mySizeY) / 2 : 0;
var left = (screen.width > mySizeX) ? (screen.width - mySizeX) / 2 : 0;

window.open(url, "_blank", "screenX=" + left + ",screenY=" + top + ",width=" + mySizeX + ",height=" + mySizeY);

<a href="javascript:centerWindow(500, 500, 'http://microsoft.com/')">Test</a>

12-27-2002, 01:24 AM
Does that make the window 500 x 500?

If it does I don't want that - I want the window to be the same size as the contents within it.

12-27-2002, 02:54 AM
What size is the content within it?

12-27-2002, 04:55 AM
Sorry if I came across as rude - I'm a little *yawns* tired :)

Well, to be honest, the size will vary.

I'm hoping someone can help me and I'm surprised no-one has thought of this or used it lol o.O

12-27-2002, 05:34 AM
What would "same size as the contents" mean? A window of any size could fit all the contents. Do u mean to say that you dont want any scroll bars but still be able to see the entire contents in the window?

12-27-2002, 11:18 AM
In a way yes - I dont want a scrollbar or a toolbar or anything but that's not the problem.

For example, say the contents take up half of the screen, the window will also be half a screen long with no excess spaces.

If you're still not sure, I'll happily provide a sceencap.

Many Thanks

12-27-2002, 02:38 PM
Can't you do the site the way 99.999% of other people do it, by making the content fit the window? Don't think I'd like a pop-up resizing itself with every page loaded in it...

You better show what you mean, coz it looks like you're confusing a lot of ppl :p

12-28-2002, 08:18 PM
Nightfire :

lol I thought I was O:-).

This (http://www.charmed-source.com/screenies/ss.png) is what I'd like it too look like.

The size will not change considerably, but it's just a design factor and I thought they'd look better in their own window.

This is what I don't want to look like:

Raaah (http://www.charmed-source.com/screenies/ss2.png)

Obviously it won't have the staus bar, it'll be just like in the previous screenshot.

Hope that's clarified it a bit!


12-29-2002, 10:19 PM