The ability to open multiple documents within the same browser window has certain practical and security implications. Consequently, many elements of the DOM behave differently when multiple tabs are open. In addition, active tabs (tabs with focus) cannot be affected by scripts run in inactive or background tabs.
For example, when only one tab is open or when tabbed browsing is disabled by the user, several window methods can affect the size, position, and appearance of the browser window. When more than one tab is open, however, these methods have no effect. This includes methods that resize, move, or otherwise change the appearance of the browser window. Similarly, the close method closes the active tab and the browser window remains open until the last tab closes.
Properties that change the appearance of a document are also limited to the active tab. For example, you can use the leftMargin property to control the left margin of the body element of the document in the tab, but you cannot change the left margin of a document in another tab.
Tabbed browsing also affects the DOM in other ways:
- New windows open as pop-up windows if any of the following features are disabled: resizable, menubar, location, toolbar, status, and scrollbars; this includes open and showHelp.
- When using the open method to open a new tab, the new tab becomes active if it was triggered through a user-initiated action, such as clicking a button. Otherwise, the new tab opens in the background and is inactive.
- Tabs do not become active when scrolled.
- In general, inactive tabs are not allowed to open windows or affect content in other tabs.
- You cannot print from inactive tabs.
- Window methods that display dialog boxes are ignored when called from inactive tabs; this includes alert, confirm, createPopup, prompt, showModalDialog, and showModelessDialog.
- New tabs will flash (and change color) for modal dialogs and some modeless dialogs. Scripts in background tabs will be temporarily suspended and dialog will be suppressed until the user switches to the tab. In addition, modeless dialogs will hide previously shown dialogs if the user switches away from the current tab; it will be shown again when the user selects the tab again.
- External methods that display dialog boxes are ignored when called by inactive tabs; this affects AddChannel, AddFavorite, and ShowBrowserUI.
- The dragDrop method is ignored for objects in inactive tabs.
Because of these changes, you should carefully review any scripts that depend on these methods; they may no longer work as intended when tabbed browsing is enabled or when run on inactive tabs.