How to embed a swf file into html code?

2020-07-27 15:57发布

问题:

I need to embed a swf file into html code. How can I do it?

回答1:

Use SWFObject:

http://code.google.com/p/swfobject/wiki/documentation

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<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>


回答2:

From w3school

<object width="550" height="400">
   <param name="movie" value="somefilename.swf">
   <embed src="somefilename.swf" width="550" height="400">
   </embed>
</object>

More info here



回答3:

You should try using flashobject. It's a Javascript utility that will detect whether the plugin is installed in a cross browser way and replace a given div with the flash object you want.

Update. I see someone else has posted a link to SWFObject. That's what I was looking for when I posted this. You should use that instead. It's more actively developed and maintained.



标签: html flash