JavaScript - Opening a new window with little to no chrome

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> </code>

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 developer advocate for Extend by Auth0. He focuses on serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support.

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

Comments