Moving Windows to the Front or Back of the Screen

Of course, once you've opened a window, you can do much more than just close it. You can move it to the front of the screen (on top of the other windows) or to the back of the screen (behind all the other windows). The focus() method brings a window forward, and blur() puts the window in back. The focus() method is especially useful when you have a window that should always appear at the front of a screen. For example, if I wanted a small navigation window to appear over the intro page, I could make all the links using this technique:

<a href = "#" onClick = "navigation = window.open('http://www.bookofjavascript.com/nav.html','navigation', 'width=605,height=350' );navigation.focus(); return false;">Navigation ...

Get The Book of JavaScript, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.