tags:

views:

9689

answers:

8

What is the best way to embed a SWF file in an HTML page?

+3  A: 
<object width="100" height="100">
    <param name="movie" value="file.swf">
    <embed src="file.swf" width="100" height="100">
    </embed>
</object>
Ólafur Waage
That code isn't XHTML-valid ... <embed> must not be within a object-tag.
Anheledir
No specification of the user to be XHTML valid, he asked for HTML
Ólafur Waage
A: 

Is this thread created to get reputation? The answer given was the first link in google. If the question is more specific where the answers are harder to find then it will be helpful for coders like me.

No offense meant just a suggestion!!!

+17  A: 

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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  <head>
    <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");
    </script>

  </head>
  <body>
    <div id="myContent">
      <p>Alternative content</p>
    </div>
  </body>
</html>

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.

Ronnie Liew
+1  A: 

I use http://wiltgen.net/objecty/, it helps to embed media content and avoid the IE "click to activate" problem.

Eduardo Campañó
The "click to activate" problem is called "eolas activation" but is removed in actual versions of the IE.
Anheledir
+1  A: 

As mentioned SWF Object is great. UFO is worth a look as well

arin sarkissian
A: 

If you are using one of those js libraries to insert Flash, I suggest adding plain object embed tag inside of <noscript/>.

Brian Kim
A: 

i have a questio please... how i can add a navigation bar (play,stop,pause,rewind,forward,back) after i embeded a flash object in my webpage so the visitor can browse the documet/movie page after page...and so on ????????????

A: 

JavaScript Embedded in an HTML File. look this example here

http://java.pakcarid.com/Cpp.aspx?sub=400&amp;ff=3157&amp;topid=40&amp;sls=25

lois