This is documentation of an archived release.
For documentation on the current version, please check Knowledge Base.

Embedding Flash in HTML

This page talks about how to embed a Flash component in a HTML page.

Manual Approach

Here's a more in-depth technote from Adobe about manual embedding.

JavaScript Assisted Approach

This approach uses a third-party javascript library to help in generating the HTML tags. This saves you from a lot of complexity you might otherwise have to deal with :

  • There's less code (you don't write the tags yourself)
  • Automatic upgrades (and upgrade checks) using Express Install.
  • Graceful degradation in case there's no javascript of Flash support.

An excellent example of such a library is SWFObject. The examples on this page will be about SWFObject.

Express Install allows Flash (from Flash Player 6 on) to automatically perform an update. This update takes place inside the flash player itself and doesn't redirect to the macromedia site. More information here.

If there is no javascript or Flash support, nothing happens and the user sees a default message.

1. Add JS Library

Add this to the head-tag.

  <script type="text/javascript" src="swfobject.js"></script>

2. Decide where the component should go

The way swfobject works is by replacing a pre-existing HTML element with the flash embedding code. The default content of this HTML element is used as a fallback. If javascript and flash are present, this HTLM element remains and is displayed to the user.

Determine where you want the flash component to be and add an element there. Give it an id attribute with a value identifying the element.

  <div id="ofmContent">
    Your browser doesn't support JavaScript. Please enable it to view this content!
  </div>

3. Let SWFObject add the component

The following example adds the flash component to the element identified by 'ofmContent' and makes the flash component available as 'ofmContentReference'.

Complete example :

  <html>
    <head>
      <script type="text/javascript" src="swfobject.js"></script>
      <script type="text/javascript">
 
        function installFlash()
        {
          var so = new SWFObject("OrbitFlashMap_modern.swf", "ofmContentReference", "640", "480", "7", "#ffffff");
          so.write("ofmContent");
        }
 
      </script>
    </head>
    <body onload="installFlash()">
      <div id="ofmContent">
        Your browser doesn't support JavaScript. Please enable it to view this content!
      </div>
    </body>
  </html>
 
Last modified:: 2019/03/25 11:36