1

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

2

3 Answers 3

10

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>
Sign up to request clarification or add additional context in comments.

5 Comments

When you posted this, it was correct but SWFObject is now deprecated. So developers would be better to look at the answer from @denislexic
@brianlmerritt Developers would be better to not use Flash at all these days.
Absolutely, but some sites still do - it's a pain!
@brianlmerritt Sure, and if you're still using Flash, you'll still have no problems with SWFObject. It's as useful now as it was before.
Let's let future visitors make up their iwb minds. Hopefully no one else will end up here, but if they do there is now a comment trail that they can follow...
9

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

5 Comments

As a rule of thumb, W3Schools is considered to be a very poor source of information and referencing it is frowned upon here. I won't downvote you for it, but others might.
@david I disagree with you. You can see its reputation over the internet. W3schools is really good for HTML/CSS information.
@imran tariq: I can see its popularity, but can you cite a source for its reputation? Regardless, in at least this community it's highly discouraged. For reference: meta.stackexchange.com/questions/87678/…
@david I'll make a note of it. Thanks.
I'll vote you up for w3schools. I often use it as quick reference when I need something. I don't learn there but it keeps the things for me I don't want to or can't remember?
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.