Note that this script uses the focus() method to bring the secondary window back again. If you don't have the Atlas Preview Release 2 (Navigator 3.0 beta 3) or later this feature won't work and you'll have to switch to the window manually the second time you write to it.
Click here to close the other window: