* Opens up a centered popup window. * @param {String} url URL to open in the window. * @param {String} name Popup name. * @param {int} width Popup width. * @param {int} height Popup height. * @param {String} options window.open() options. * @return {Window} Returns window instance.
(url, name, width, height, options)
| 589 | * @return {Window} Returns window instance. |
| 590 | */ |
| 591 | function popup(url, name, width, height, options) |
| 592 | { |
| 593 | var x = (screen.width - width) / 2, |
| 594 | y = (screen.height - height) / 2 |
| 595 | ; |
| 596 | |
| 597 | options += ', left=' + x + |
| 598 | ', top=' + y + |
| 599 | ', width=' + width + |
| 600 | ', height=' + height |
| 601 | ; |
| 602 | options = options.replace(/^,/, ''); |
| 603 | |
| 604 | var win = window.open(url, name, options); |
| 605 | win.focus(); |
| 606 | return win; |
| 607 | }; |
| 608 | |
| 609 | /** |
| 610 | * Adds event handler to the target object. |