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.

<p><a href="javascript:window.close()">Close</a></p>
will close a page, but it's even better to add this line as well
<body onBlur="javascript:window.close()">
which will close it as soon as the user goes elsewhere, and no-one likes having lots of little orphan windows still open.

You can only close a window if you opened the window and the same page as you first loaded into the window is still displayed in it.

You can't guarantee that any code will open a new window because where new pages open is completely under the control of your visitors - they may prefer to have it open in a new tab or even the same tab instead and there is no way you can prevent that or tell where they have opened it.

In this way, the link will always work because the href attribute does have an address.

Remember that pop-ups are unreliable because they have been abused badly. Most browsers come with pop-up blockers and some users have javascript turn off, so don't place any critical information there because your users may not see it. If anything, something that can help them but they don't need to enjoy the site.