JavaScript - Opening a new window with little to no chrome

This post is more than 2 years old.

This is an old question, covered in hundreds of FAQs, but a reader asked me this today and I'm nothing if not responsive. (Especially when I know the answer. ;) The question was - how do you open a new window in JavaScript with as little chrome as possible. JavaScript makes this rather simple. The syntax to open a new window is:

foo = window.open(url, varname, features);

Where features is a list of ... well, features. This includes chrome, size, and other options. I found a good list here.

So to answer the question - you can simply disable all the features that are chrome related like so:

<script> function popup() { var features = 'directories=no,menubar=no,status=no,titlebar=no,toolbar=no,width=500,height=500'; var mypopup = window.open('http://ray.camdenfamily.com', 'mypopup', features); } </script>

<form> <input type="button" onclick="popup()" value="Click me, baby"> </form>

In my features list I disabled directories, menubar, status, titlebar, and toolbar. Note though that status=no will not work in Firefox or IE7, due to security settings, which is probably a good thing.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Archived Comments

Comment 1 by Jay McConathy posted on 12/8/2006 at 9:18 PM

that is nice.

I am wondering if it is possible to do something like a cflocation where on opening if the initial page it redirects them to a "chromeless" page instead of having to use a button?

Comment 2 by Jay McConathy posted on 12/8/2006 at 9:20 PM

or would it be possible to use an "OnLoad" style startup of the page and call it then?

Comment 3 by Raymond Camden posted on 12/8/2006 at 9:20 PM

You can run JS code when the windows loads. That would remove the need to click a button.

Comment 4 by Jay McConathy posted on 12/8/2006 at 9:21 PM

Being a javascript dunce do you have an example??

Comment 5 by Raymond Camden posted on 12/8/2006 at 9:28 PM

Use this in the body:

<body onload="popup()">

Comment 6 by Scott Stroz posted on 12/9/2006 at 12:35 AM

Odds are, pop-up blockers will block a window opening if you do it with <body onload="..." >

Comment 7 by Edward T posted on 12/9/2006 at 3:05 AM

A little tip that I use is to add a focus() call to the window (e.g., mypopup.focus();) as the final line in the popup() function. The reason is that if the window has already been popped, but is buried (behind the current window, minimized, etc.), this will bring it forward.

/ejt

Comment 8 by Larry C. Lyons posted on 12/11/2006 at 1:50 AM

Hi Ray,

Funny that you should mention chromeless popup windows. I was just reading a very good article about this on the A List Apart web site, (http://alistapart.com/artic.... What's really nice about the popup window code discussed in the article is that it passes most accessibility validators.

regards,

larry

Comment 9 by Raymond Camden posted on 12/11/2006 at 3:37 AM

Nice link, thanks!

Comment 10 by Alex posted on 4/16/2007 at 3:53 AM

Great guide! i use it to open itunes songs.