www.fgks.org   »   [go: up one dir, main page]

Click to Rate and Give Feedback
HTML and DHTML Overviews and Tutori...
 Tabbed Browsing for Developers
Tabbed Browsing for Developers

Tabbed browsing in Windows Internet Explorer 7 affects the Document Object Model (DOM) and the WebBrowser Control. This topic describes the effects on the DOM, shows how applications hosting the WebBrowser Control can enable tabbed browsing shortcuts, and describes notifications useful to those writing Internet Explorer 7 extensions.

This topic contains the following sections.

Introduction

Internet Explorer 7 introduces tabbed browsing, which allows users greater control over the way they interact with the Web. Pages can be displayed in separate tabs, separate windows, or any combination of the two.

Tabbed browsing also affects the DOM. Certain behaviors change when more than one tab is open. In addition, applications hosting the WebBrowser Control do not automatically support tabbed browsing shortcuts. This support is managed with a registry key. Finally, new notifications allow Internet Explorer 7 extensions to respond to tab-related events.

Document Object Model Changes

The ability to open multiple documents within the same browser window has certain practical and security implications. Many elements of the DOM behave differently when multiple tabs are open. Active tabs (tabs with focus) cannot be affected by scripts that run in inactive or background tabs. Similarly, the close method closes the active tab, and the browser window remains open until the last tab closes.

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. This includes methods that resize, move, or otherwise change the appearance of the browser window. When more than one tab is open, however, these methods have no effect.

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 active 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 windows opened with open and showHelp.
  • When the open method is used to open a new tab, the new tab becomes active if it was triggered by a user 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 cannot open windows or affect content in other tabs.
  • You cannot print from inactive tabs.
  • Window methods that display dialog boxes are ignored when they are called from inactive tabs. Those methods include alert, confirm, createPopup, prompt, showModalDialog, and showModelessDialog.
  • New tabs flash (and change color) for modal dialog boxes and for some modeless dialog boxes. Scripts in background tabs are temporarily suspended and dialog boxes are suppressed until the user switches to the tab. In addition, modeless dialog boxes hide previously shown dialog boxes if the user switches away from the current tab; ithe dialog box will be displayed when the user selects the tab again.
  • External methods that display dialog boxes are ignored when called by inactive tabs. These methods include 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 they are run on inactive tabs.

Enabling WebBrowser Control Shortcuts

In Internet Explorer 7, you can open links in new tabs in several ways.

  • Choose the "Open in New Tab" command from a link's shortcut menu.
  • Click the link with the wheel button.
  • Hold the CTRL key and click the link.

For compatibility reasons, however, these shortcuts are disabled for applications hosting the WebBrowser Control.

Note  While these features are disabled by default, related commands appear on the WebBrowser Control shortcut menu. For information on displaying a custom shortcut menu, see WebBrowser Customization.

You can enable these shortcuts by adding your application file name to the FEATURE_TABBED_BROWSING registry key.

  • HKEY_LOCAL_MACHINE (or HKEY_CURRENT_USER)
    • SOFTWARE
      • Microsoft
        • Internet Explorer
          • Main
            • FeatureControl
              • FEATURE_TABBED_BROWSING

              • application name.exe = 0x00000001
Note   This does not cause the WebBrowser Control or your application to display multiple tabs. Instead, it enables the tabbed browsing shortcuts described earlier. If a user of your application opens a link in a new tab when these shortcuts are enabled, the WebBrowser Control opens the link in a new Internet Explorer 7 window.

For more information on optional features and how to enable them, see INTERNETFEATURELIST.

Tab-Related Notifications

When applications hosting the WebBrowser Control enable tabbed browsing shortcuts, they can receive and respond to notifications that occur when the user initiates a tab-related action, such as opening a link in a new tab.

These notifications arrive through the DWebBrowserEvents2::NewWindow3 event. The dwFlags parameter can include the following flags:

  • NWMF_FORCEWINDOW: User opened a link in a new window.
  • NWMF_FORCETAB: User opened a link in a new tab.
  • NWMF_INACTIVETAB: An inactive tab tried to open a window.

Applications that provide their own tabbed interfaces can use these flags to respond to the user. Users writing extensions, such as custom toolbars, browser helper objects (BHOs), and other add-ons, can use these notifications to customize Internet Explorer 7.

For information on creating extensions, see Browser Helper Objects: The Browser the Way You Want It World Wide Web link.

Tags What's this?: Add a tag
Community Content
 
Add Community Content
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker
DCSIMG