Search Search

#1 worldwide
FREE Coding Lessons

since 1996
   THE BEST WAY to learn ASP & Asp.net!
Advertise Here!
click for details
Credits Host:
DiscountASP.net
Server Admin:
The "Team"
Contact Info.
Charles M. Carroll

my Blog
[prev. Lesson]  BrowserHawk - Frame support
     [next Lesson]  ServerObject Mail: Simple Example

Detecting Flash plug-in support

The Macromedia Flash plug-in provides a great way to liven up your web site.  With Flash you can make fancy splash screens, animated graphics, interactive presentations, and much more.  The downside?  Not all of your visitors will have the Flash plug-in installed, and therefore will not experience your site as you'd expect. :(

While it's true that Internet Explorer will automatically attempt to download and install the Flash player if not already installed, many people find this to be highly intrusive. As a result, developers prefer only to serve Flash content to Flash capable browsers.  In addition, this automatic download isn't an option for users of other popular browsers, such as Netscape Communicator.

By using the approach demonstrated here, however, you can have an alternative plan up your sleeve, and be ready to serve non Flash folks with a suitable alternative.

Let's assume you have a fancy Flash animation on your home page waiting to dazzle your visitors, and that this animation requires the Flash 4 plug-in to be installed. To make sure that visitors without Flash 4 will not be left staring at a blank home page, you'll want to provide an alternative such as an image where the Flash animation would normally go.

Here is a summary of the steps needed to implement this approach:

  • detect whether their browser has the Flash 4 plug-in installed
  • if they have Flash 4, send the HTML back to the browser which will start the Flash movie playing
  • if they do not have Flash 4, send the HTML back to the browser which displays a standard image in its place - along with a tiny note that the site is best used with a Flash capable browser.

The toughest part of this approach is determining whether the visitor has the Flash 4 player installed in their browser.  Fortunately BrowserHawk 2000 makes detecting Flash support as simple as calling a single method and checking the Plugin_Flash property.

   filename=/browserhawk/flashcheck.asp

<Test Script Below>


<%
set bh = Server.CreateObject("cyScape.browserObj")
bh.GetExtProperties "BGCOLOR=#FFFFFF"

'Note: The above method must be called before the HTML tag.
'Pass in the background color used by your site as shown above
'for best results. See the BrowserHawk documentation for more
'details on using this method.
%>

<HTML><HEAD><TITLE>Flowers 'n Things Home Page (Demo)</TITLE></HEAD>
<BODY>
<CENTER><H3>Welcome to Flowers 'n Things!</H3></CENTER>

<%
flashVer = bh.Plugin_Flash

  if flashVer >=4 then %>

  <!-- Code for Flash 4 users goes here -->

  <CENTER>
  <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
   codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0"
   ID=Flower WIDTH=360 HEIGHT=360>
   <PARAM NAME=movie VALUE="Flower.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <embed src="Flower.swf" quality="high" bgcolor="#FFFFFF" WIDTH="360" HEIGHT="360" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">
  </OBJECT><BR>
  </CENTER>
  <HR WIDTH=400>
  <CENTER><TABLE WIDTH=400><TR><TD>
  Lesson note: This is the page shown to all visitors with the Flash 4 plug-in or higher installed. If they
  did not have Flash 4 installed, we would have presented <A HREF="flower.gif" WIDTH=360 HEIGHT=360>this image</A>
  instead of the Flash animation above. This script uses cyScape's <A HREF="http://www.cyscape.com/products/">BrowserHawk</A> to determine whether Flash is installed.
  </TD></TR></TABLE></CENTER>

<% else %>

<!-- Code for Non-Flash 4 users goes here -->

  <CENTER><IMG SRC="flower.gif" WIDTH=360 HEIGHT=360></CENTER><BR>
  <CENTER><FONT SIZE=-1>Best viewed with <A HREF="http://www.macromedia.com/shockwave/download/?P1_Prod_Version=ShockwaveFlash">Macromedia Flash 4</A></FONT></CENTER>
  <HR WIDTH=400>
  <CENTER><TABLE WIDTH=400><TR><TD>
  <%
  msg = ""
  if flashVer = 0 then
    msg = "You do not have Flash installed."
  elseif flashVer = -1 then
    msg = "It is not possible with your browser/platform to detect whether your Flash is installed."
  else
    msg = "You have Flash version " & flashVer & " installed."
  end if
  %>
  Lesson note: <% =msg%> This is the page shown to all visitors without the Flash 4 plug-in or higher installed. Since
  their browser does not support Flash, we provide them with this alternative graphic for the home
  page.  This script uses cyScape's <A HREF="http://www.cyscape.com/products/">BrowserHawk</A> to determine whether Flash is installed.
  </TD></TR></TABLE></CENTER>

<% end if %>

</BODY></HTML>

Need a copy of BrowserHawk? See our section on Getting Started.

Copyright (c) 2000 cyScape, Inc.  All rights reserved.  This material may not be published, distributed, or reprinted without written consent from cyScape.

Chaz Wish List
Tall Tip $5
Grande Tip $20
Venti Tip $39
Tip Jar Thanks
2004 Thanks
2005 Thanks
HUGE Tip -love site