DekGenius.com
Previous Section Next Section

12.7 Browser Configuration Behaviors

Earlier, we saw the Call JavaScript behavior in action. Let's explore three more DW behaviors, which, like all behaviors, are applied via the Behaviors panel. We'll examine other behaviors in subsequent chapters.

12.7.1 Check Browser

The Check Browser behavior sends the user to different pages based on the browser's brand and version. Applying the Check Browser behavior (typically to the <body> tag) opens the dialog box shown in Figure 12-9, where you can set its parameters.

Figure 12-9. Check Browser behavior parameters
figs/dwn_1209.gif

This behavior splits visitors into three groups depending on whether you select the Stay On This Page, Go To URL, or Go To Alt URL option. You can change the version number used to discriminate between browsers (i.e., you don't have to leave it at Version 4.0 for either brand, and it doesn't need to be the same for both brands). You can use this behavior to separate users by brand, rather than by version, by sending all Netscape users to one URL and all Internet Explorer users to the Alt URL. You can apply the same behavior (with different parameters) to subsequent pages to discriminate even further.

Note that this behavior works with Version 3+ browsers, except for IE on the Macintosh, which requires Version 4 or later. Therefore IE3 on the Macintosh, like all browsers that don't support JavaScript, will stay on the current page. You should set the Other Browsers pop-up menu option to Stay On This Page, which handles browsers whose brand the behavior can't determine.

Some browsers provide false header information when they identify themselves to your server. They aren't being deceptive intentionally, but rather stating that they should be treated as if they were one of the major browsers. As alluded to at the beginning of the chapter, no browser detection script works flawlessly with all browsers, so test carefully or let the user manually choose which version of your site to visit.

12.7.2 Check Plugin

The Check Plugin behavior sends the user to different pages based on whether the visitor's browser has a particular plugin installed. Applying the Check Plugin behavior (typically to a button or to the <body> tag) opens the dialog box shown in Figure 12-10, where you can set its parameters.

Figure 12-10. Check Plugin behavior parameters
figs/dwn_1210.gif

Select the name of the plugin from the existing list (Flash, Shockwave, LiveAudio, Netscape Media Player, or QuickTime) or enter its name manually. The specified name must match the plugin name found under Netscape's About Plug-ins command (which is under the Netscape Help menu on Windows or the Apple menu on the Mac).

Specify the URLs of the pages to load if the plugin is (or is not) detected. Checking for plugins isn't always reliable; IE3 and IE4 on the Mac can't detect plugins, and sometimes automated detection fails when new browsers are released. Furthermore, this behavior doesn't distinguish between different versions of a plugin (such as the Flash 4 Player versus the Flash 5 Player).

To detect the Flash plugin's presence and version number, see the Moock Flash Player Inspector at http://www.moock.org/webdesign/flash/detection/moockfpi/.

Although IE doesn't support the use of JavaScript to test for Netscape-style plugins, if an ActiveX version of the plugin is available, IE for Windows downloads it automatically if needed. See Chapter 5 for details. If running on IE5 or later on the Mac, this behavior inserts a VBScript function that tests for the plugin.

Therefore, you should either ask users to tell you if they have the plugin installed, or enable the "Always Go to First URL if Detection is not Possible" checkbox. The latter assumes that visitors have the plugin if its presence can't be determined (this applies primarily to Internet Explorer because Netscape can always detect plugins). Sending the user to a page containing content that requires a plugin will often cause the browser to prompt the user to download the plugin.

Always give your visitors the option to tell you that they have the right plugin or an easy way to download it if they don't. Some plugins, such as QuickTime and Shockwave for Director, can be installed using off-line installers licensed from the software publisher.

When using plugins, ensure that the server MIME types are set correctly for the media file types being served. If the user can't view the content, it may be because of a server MIME configuration problem or the user may truly lack the plugin. The MIME type for each plugin is listed under Netscape's About Plug-ins command (which is under the Netscape Help menu on Windows or the Apple menu on the Macintosh).

12.7.3 Open Browser Window

The Open Browser Window behavior is used to load a document in a new window. The behavior's parameters are set in the dialog box shown in Figure 12-11.

Figure 12-11. Open Browser Window behavior parameters
figs/dwn_1211.gif

Uncheck the window Attributes shown in Figure 12-11 to eliminate window embellishments such as toolbars. Specify a Window Name if the window is targeted by hyperlinks or controlled via JavaScript (the Window Name must not contain spaces or special characters).

This MM_openBrWindow function inserted by the Open Browser Window behavior simply calls the JavaScript window.open( ), as shown here:

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

By default, it is triggered by the onLoad event of the <body> element, as shown here:

onLoad="MM_openBrWindow('url.htm','newWindow','status=yes,
    scrollbars=yes,width=400,height=600')"

To use this function with the Check Browser or Check Plugin behavior, you will need to modify the JS of those behaviors. For example, this statement in the Check Plugin behavior loads the specified URL into the current window:

if (theURL) window.location=theURL;

To use the MM_openBrWindow function to direct the contents to a new window, you can replace the window.location=theURL statement with the function call to MM_openBrWindow:

if (theURL) MM_openBrWindow('url.htm','newWindow','status=yes,
    scrollbars=yes,width=400,height=600')"

To close a window, use the Call JavaScript behavior (as described earlier) to execute the window.close( ) JavaScript function. Avoid using the onUnload event to open another window when a user closes a browser window (it is really annoying).

The next chapter covers Dreamweaver behaviors that affect images in your HTML documents.

    Previous Section Next Section