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.
Archived Comments
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?
or would it be possible to use an "OnLoad" style startup of the page and call it then?
You can run JS code when the windows loads. That would remove the need to click a button.
Being a javascript dunce do you have an example??
Use this in the body:
<body onload="popup()">
Odds are, pop-up blockers will block a window opening if you do it with <body onload="..." >
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
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
Nice link, thanks!
Great guide! i use it to open itunes songs.