The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

How do you specify new window width and height?

Hi,

I'm creating a link to my javascript calculator. I want the link to load the calculator on a new page of course, but the window should just fit the width and height of the calculator, so the person can still do calculations and still be able to see the page underneath. How do you do that? Like specify the new window's height and width?

This is a bit like those annoying popup advertisements which have no title bar or close button, just an image faking a close button and some text. I hope you know what i mean. I want a small window to pop up so ppl can use it, not another big browser window.

There are a number of ways you can customise the window and make the script more reusable for any other popup windows you may want to have on your site, but this is the most basic way of doing just what you need at the moment.

If you want to know ways of making it more resuable then just let us know

...somewhere in the <a> tag of the item/text you wish to use to trigger the new window*.

* For image links, you don't actually need to create an <a> tag around it to make it respond to an onclick event. You can actually put it directly within the <img> tag itself, but you will not get the usual pointer (hand) cursor when you mouseover it unless you add a little css.
You can actually still put the onclick into the img tag without the need for css by putting 'dead' links around the img tag...

<a href="#"><img src="calculator.gif" onclick="popCalc()"></a>

For now using an <a> tag and having the onlick in there is still the less problematic (most popular) way.

Went off on bit if a tangent, there, but threw it in just in case you were interested

Certain browsers support the titlebar window property that can be referenced with the features of the window.open command.
I'm not totally sure which browsers do and which don't, but I believe support is limited(?) to only IE4+ on PC.

One alternative is a 'chromeless window', which removes *all* the window edges (chrome) and shows just the contents of the html body.

However, this is neither universally popular with web-users or universally supported by browsers. (just so you're aware).
I, personally, have never actually seen one of these in use as Macintosh doesn't support it (nor do I particularly want it to)

Anywho...
You can check out the neccessary script for chromeless windows at Microbians.com.

And yes for the close button...
Make it clear simple for users to close the window again with the mouse as the 'window' will no longer have the close button along the title bar.
This is one of the most overlooked elements of pages show in such windows and is the number objection to using them at all.

Those platforms and browsers that do not support these functions should simply get a 'normal' popup window (i.e. one with window chrome and title bar (incl. close button*)

* It is generally more user-friendly to include a close button/link in *all* popup windows, even those that still have a title bar.