Site design strategies for Shockwave Player detection
Please be sure to also visit the Director support center for additional TechNotes and articles concerning Director and Shockwave web deployment.
It is important to consider what might happen if a user visits your site with a browser that does not have the Shockwave Player installed. There are two basic methods for controlling the user's experience.
-
Rely on the default behavior
-
Player detection
Default behavior for the Shockwave Player plug-in in Netscape and Firefox (Windows and Macintosh)
If a user arrives at a page with a Shockwave movie, and they do not have the Shockwave Player installed, the movie will not play. Instead, the Shockwave movie is displayed as a white rectangle with a plug-in icon in the center. Below the icon, the words "Click here to get the plug-in" appear. If the user clicks on the icon, the default behavior presents them with a new page that attempts to determine the appropriate path to obtain the installer for the necessary plug-in installer. During this process, the user may get lost. Although they may be successful in installing the player, they still have to navigate back to the original page to view the movie that requires the plug-in.
This is how a Shockwave movie will display if the player is not present.
Note: While this process is similar across browsers, the behavior described above is specific to Netscape Communicator 4.5 and later. Other plug-in based browsers immediately present a dialog box, instructing users in the steps to follow to download the installer.
This default behavior of plug-in based browsers (which includes Netscape and Firefox running on Windows and all Macintosh browsers) may be considered unacceptable in some circumstances. However, the experience can be tailored to a specific site's requirements by using the "pluginspage" parameter.
Modifying the default plug-in experience using the "pluginspage" parameter
In an effort to provide a bit more control, plug-in based browsers allow a parameter to be included in the <EMBED> tags for a Shockwave movie. This parameter, the pluginspage parameter, specifies a URL which will be linked if the user clicks on the broken icon. While it is most common for this URL to take the user to the plug-in manufacturer's web site to download the player, some developers choose to change this URL. It is possible to change this URL to whatever you feel is appropriate for your site.
The Macromedia default pluginspace URL
Implementation of the Pluginspace parameter
<embed href="/support/director/ts/documents/movie.dcr"pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveDirector" type="application/x-director" ></embed>
The biggest drawback of using the pluginspace parameter is that in some cases (when the user is on Netscape), it causes a dialog box to appear, prompting the user to confirm that they want to go to your specified URL to get the necessary plug-in.
This is an illustration of the confirmation dialog that appears when the pluginspace parameter is used.
While the default plug-in experience can get a user through the Shockwave download, its drawbacks are significant. The default experience for ActiveX-based browsers (Internet Explorer on Windows) is far friendlier and is referred to as 'autoinstall'.
Default behavior for Internet Explorer on Windows only
Autoinstall is a mechanism provided by Internet Explorer to allow for the automatic installation of ActiveX controls included on a Web page. Since the Shockwave Player in Internet Explorer is an ActiveX control, it can take full advantage of this solution. By properly formatting the <OBJECT> tag in the HTML used to represent your movie, you can trigger an installation of a specific version of Shockwave with minimal effort.
By specifying a URL to Shockwave's "cab" installer using the codebase parameter in the <OBJECT> tag (which an HTML authoring tool like Dreamweaver will do for you automatically), the object will trigger an installation of a missing ActiveX control. By further appending version information to the codebase (with the text "#version=" followed by the version tag), you can specify when the download of a newer control may be necessary. For example, a user may have the Shockwave 7 player, but the movie on your page may require the Shockwave 8 player. By specifying version 8 in the tag, you can cause users without the required version to install it. For users with Shockwave 8, the movie will play as expected.
Note: Even if the specified required version is less than the latest version of Shockwave, the install should always install the latest version.
Note: Visitors using Internet Explorer on Windows XP Service Pack 2 may have differing experiences. Visit ourXP Service Pack 2 Support Center for more information.
The URL to the cab installer
http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab
The codebase tag with a version specified
<object classid="clsid:166B1BCA-3F9C-11CF-8075-444553540000"codebase="http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=10,0,0,0" ><param name="src" value="movie.dcr"><param name="bgcolor" value="#000000"></object>
Shockwave version tags:
| Player | Version |
6 |
6,0,1,159 |
7 |
7,0,0,205 |
8 |
8,0,0,196 |
8.5 |
8,5,0,0 |
10.1 |
10,0,0,0 |
While autoinstall seems like a great solution, it also has a couple of drawbacks. First, the user will likely be prompted by their browser with a security dialog asking for their permission to install the player. While a user will generally grant this permission, the messaging in this dialog is not entirely straightforward, and its emphasis on security may prompt your user to choose "No". Secondly, the Shockwave ActiveX Player download may take a few minutes to complete over a modem connection. During the autoinstall process, the dialog prompting the user for permission may not appear at all until after a percentage of the player has completed downloading -- in other words, it may take a couple of minutes before anything at all happens. To the user, the page may appear to "hang" for a short time before they get a clear idea of what is happening.
The autoinstallation security dialog
A Shockwave movie during autoinstallation
Regardless of these behaviors, the autoinstall process is often considered an adequate user experience for the Shockwave download process. It would be nice, however, if your site could determine automatically if the user has the Shockwave player. That way, for people who don't have the player, your site could message appropriately to prepare a user for what to expect during the download process. To do this, you need to include detection scripting.
back to topWarning the visitors that a plug-in is necessary to view the provided content
If you choose not to use detection altogether and rely on the default behavior, you should consider providing an appropriate message to the visitor. This strategy involves alerting them that the Shockwave Player is required BEFORE they navigate to a page with a Shockwave movie on it. This obviously does not stop a user without Shockwave from visiting the page anyway. While this solution is not very elegant, it is important to consider. Depending on your available resources, the complexity involved in some of the other solutions described in this document may not be practical.
While evaluating this scenario, it's important to understand thedefault behavior of the browser when a user without the player ignores the messaging and attempts to visit the page. This default behavior may or may not comprise an acceptable user experience for your site.
Player detection using client-side scripting
Information identifying the type of a user's browser is provided to your server with every request, but no information is provided about what plug-ins or ActiveX controls a visitor may have installed (the Shockwave Player resides completely on the user's machine). The only way for your site to tell if a user has the Shockwave Player is to do client-side scripting. This means that some amount of JavaScript and or VBScript code will be needed on any HTML page for Shockwave Player detection. Since client-side scripting can make HTML pages more difficult to maintain, some sites choose solutions that don't use scripting.
There are many variations on detection. Depending on the user's browser, that page may need JavaScript or VBScript on it (or both). You may decide that you want to do detection for both browsers. Or you may decide that the autoinstall process is adequate for Internet Explorer users but that you want to do detection for Netscape users to tailor the experience a bit more.
Plug-in detection in Netscape (Macintosh and Windows)
ActiveX control detection in Internet Explorer for Windows
Plug-in detection in Netscape (Macintosh and Windows)
Netscape provides an easy mechanism for detecting plug-ins through JavaScript. It is called the "Plug-ins Array".
Netscape provides access to the Plug-ins array through its JavaScript API . The Plug-ins array contains a list of plug-ins available to a browser.
Accessing the Array
var thearray = navigator.plugins;
To detect Shockwave, a script can check the properties of each plug-in in the list to see if it's the Shockwave Player. Each plug-in within the list is a Plug-in object with two relevant properties, the name and the description. The values of these properties provide enough information to find out if the plug-in is the Shockwave Player.
Looking through the array
var thearray = navigator.plugins; var arraylength = thearray.length; for (i=0; i<arraylength; i++) { theplugin = thearray[i]; // Retrieve the plugin thename = theplugin.name; // Get the plugin name thedesc = theplugin.description; // Get the plugin description }
Note: Some 4.0x versions of Netscape Navigator suffer from a crashing bug related to the Plug-ins Array. It's important to set local variables when checking values in the array, particularly when stepping through each object in the array.
You can test the value of the plug-in's name property to see if the plug-in is the Shockwave Player.
Testing for Shockwave
if (thedesc.indexOf("Shockwave") != -1 && thedesc.indexOf("Director") != -1) { isShockwave = true; }
For the Shockwave Player, the description property contains version information in the following format:
Macromedia Shockwave for Director Netscape plug-in, version x.xx
To get the major version from this string, simply parse out the version number at the end of the string, then parse out the integer from it.
Getting the major version
// Parse out the version versionString = thedesc.substring(thedesc.indexOf("version ") + 8); // Get the major version majorVersion = parseInt(versionString);
Given this, detecting for a major version of the Shockwave Player can be wrapped up in the following JavaScript function:
A Shockwave detection function
//**************************************************************** // // JavaScript Function: // getShockwaveVersion() // // Description: // Returns the major version of the installed Shockwave Player // plug-in, or zero if the player is not installed. // //**************************************************************** function getShockwaveVersion() { // Set local variables to avoid crashing bug var thearray = navigator.plugins; var arraylength = thearray.length; for (i=0; i<arraylength; i++) { theplugin = thearray[i]; // Retrieve the plugin thename = theplugin.name; // Get the plugin name thedesc = theplugin.description; // Get the plugin description // If the plugin is the Shockwave Player... if (thedesc.indexOf("Shockwave") != -1 && thedesc.indexOf("Director") != -1) { // ...parse out the version... versionString = thedesc.substring(thedesc.indexOf("version ") + 8); // ...pet the major version... majorVersion = parseInt(versionString); // ...and return it. return majorVersion; } } // If we've went through the whole list of plugins without // finding Shockwave, we return zero. Return 0; } // USAGE: // // Checking for the presence of the Shockwave Player: // if ( getShockwaveVersion() ) { ... } // // Checking for a specific version of the player: // if ( getShockwaveVersion() >= 7 ) { ... } //
ActiveX Control detection in Internet Explorer for Windows
Unfortunately, Internet Explorer does not have an easy-to-use Plug-ins Array type object to get at ActiveX control information. In fact, Internet Explorer provides no JavaScript interface to ActiveX controls at all. Instead, Visual Basic Script (or VBScript) is required.
VBScript does not provide the equivalent to Netscape's Plug-ins Array. However, it is possible with VBScript to create an ActiveX control on the fly using the function CreateObject( ). By manipulating this functionality, it is possible to determine the major version of the Shockwave Player that a user has installed.
The CreateObject( ) function takes a single string parameter, the class name of object to create. For the Shockwave Player, the value of the class name is "SWCtl.SWCtl". By attempting to create a Shockwave Player ActiveX control and then checking to see if the creation was successful (by using the IsObject( ) function, you can tell whether or not the user has Shockwave installed.
Trying to create an ActiveX control
Dim swControl, hasShockwave on error resume next set swControl = CreateObject("SWCtl.SWCtl") if (IsObject(swControl)) then set hasShockwave = True else set hasShockwave = False end if
Additionally, it is possible to test for a major version of the Shockwave Player by slightly modifying the class name when trying to create the ActiveX control. Different versions of the Shockwave Player ActiveX control are distinguished by appending the class name with ".X" where X is the version number. By trying to create a specific version of the player, you can determine the major version of the player installed.
Trying to create a specific version of the control
Dim swControl, hasShockwave7 on error resume next set swControl = CreateObject("SWCtl.SWCtl.7") if (IsObject(swControl)) then set hasShockwave7 = True else set hasShockwave7 = False end if
Current available class names:
| Class name | Description |
SWCtl.SWCtl |
The generic ActiveX control. |
SWCtl.SWCtl.1 |
Shockwave Player, version 6 |
SWCtl.SWCtl.7 |
Shockwave Player, version 7 |
SWCtl.SWCtl.8 |
Shockwave Player, version 8 |
To wrap this technique up into a function, you can start at a high-version class name and keep trying to create a control until you succeed. Once you succeed, you know which version of the player you have.
Detecting the Shockwave ActiveX control
Function VBGetShockwaveVersion() ' Catch and ignore errors on error resume next ' Our variables Dim swControl, swVersion ' Set a default version set swVersion = 0 ' Step down through possible versions starting with version 8. ' (You could set this number higher to plan for future versions '>of the Shockwave Player) For i = 8 To 1 Step -1 ' Set up the classname for the version that we're trying Dim classname classname = "ShockwaveFlash.ShockwaveFlash." + CStr(i) ' Try to create a control of that version set swControl = CreateObject(classname) ' If we succeeded... if (IsObject(swControl)) then ' ...then set our version and stop trying. set swVersion = i Exit For end if Next ' Since the classname for Shockwave 6 actually has the ' version number "1", we need to catch this case and ' set it properly. if (swVersion = 1) then swVersion = 6 ' Set the return value for the function VBGetShockwaveVersion = swVersion end Function
Note: It is possible to call a VBScript Function defined on a page using JavaScript on that page. Therefore, it is straightforward to incorporate the above VBScript detection solution into a more generalized JavaScript-based script solution.
Browsers that cannot use detection
Not all browsers can use detection. Notable examples include Internet Explorer 4.5 for the Macintosh and Internet Explorer 3.0x for Windows. The strategy you decide upon is up to you, but it is recommended that you perform some sort of detection to determine whether the browser you are dealing with is one which cannot do detection.
This determination can be made by the server using the value of the user agent string, or it can be made on the client-side using the navigator JavaScript object.
Determining if the browser can detect
function canDetectShockwave() { // Determine the browser (IE or Netscape) using navigator.appName var ie = (navigator.appName.toLowerCase().indexOf("microsoft") != -1); var ns = (navigator.appName.toLowerCase().indexOf("netscape") != -1); // Determine the platform using navigator.platform var win = (navigator.platform.toLowerCase().indexOf("win") != -1); var mac = (navigator.platform.toLowerCase().indexOf("Mac") != -1); // Determine the browser version var browserVer = parseFloat(ie ? navigator.appVersion.substring(navigator.appVersion.toLowerCase().indexOf("msie") + 4) : navigator.appVersion); // Return the appropriate value based on the browser, version and platform if (ie && win) return (browserVer >= 4.0) // Works in Windows IE 4.0 and better if (ie && Mac) return (browserVer >= 5.0) // Works in Mac IE 5.0 and better if (Ns) return (browserVer >= 3.0) // Works in Netscape 3.0 and better // If none of the above conditions matched, the browser is // unknown and likely doesn't support detection return false; }
Code examples
The three HTML files below include the JavaScript, VBScript and HTML necessary to perform Shockwave Player detection. These samples can be used to help you develop the implementation specific to your needs. The source code in these HTML pages contains the relevant information, so you will need to view the HTML source code in an HTML editor or in a browser with the view option enabled to view source code.
The files contain a selection of Shockwave player detection functions that are built using the techniques described in this document. The plug-in detection script for Netscape is expanded slightly to account for minor version information (Shockwave 7.03 and so forth). The functions have also been expanded to include the ability to pass in a specific version of the player that you'd like to detect. The functions in the file can be individually included on your HTML page as you see fit.
- detect_ax_shockwave.html
An HTML page that includes the functions in shockwaveDetect.js and uses them to detect the Shockwave Player ActiveX control. This page only works in Internet Explorer on Windows. - Detect_Ns_shockwave.html
An HTML page that includes the functions in shockwaveDetect.js and uses them to detect the Shockwave Player plug-in. This page only works with plug-in enabled browsers like Netscape Navigator (Windows and Macintosh) and Internet Explorer on the Macintosh. - Detect_old_browser.html
An HTML page that performs browser detection to determine if the current browser is capable of performing Shockwave detection using JavaScript or VBScript.
This content requires Flash
To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player.
Download the free Flash Player now!
