ioSamurai ioSamurai - 1 month ago 5x
HTML Question

How to embed a SWF file in a html page?

How do you embed a SWF file in an HTML page?


The best approach to embed a SWF into a HTML page is to use SWFObject.

It is a simple open-source Javascript library that is easy-to-use and standards-friendly method to embed Flash content.

It also offers Flash player version detection. If the user does not have the version of Flash required or has Javascript disabled, they will see a alternate content. You can also use this library to trigger a Flash player upgrade. Once the user has upgraded, they will be redirected back to the page.

An example from the documentation:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="" lang="en" xml:lang="en">
    <title>SWFObject dynamic embed - step 3</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <script type="text/javascript" src="swfobject.js"></script>

    <script type="text/javascript">
    swfobject.embedSWF("myContent.swf", "myContent", "300", "120", "9.0.0");

    <div id="myContent">
      <p>Alternative content</p>

A good tool to use along with this is the SWFObject HTML and Javascript generator. It basically generates the HTML and Javascript you need to embed the Flash using SWFObject. Comes with a very simple UI for you to input your parameters.

Highly Recommended and very simple to use.