I need to embed a swf file into html code. How can I do it?
Asked
Active
Viewed 5.1k times
1
-
possible duplicate of [Best way to embed a SWF file in a html page?](http://stackoverflow.com/questions/137326/best-way-to-embed-a-swf-file-in-a-html-page) – Trufa Apr 18 '11 at 16:34
-
this site is not ideal for asking this sort of questions. Please take a look at our FAQ. http://stackoveflow.com/faq – Trufa Apr 18 '11 at 16:52
3 Answers
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>

Brad
- 159,648
- 54
- 349
- 530
-
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 Oct 23 '17 at 09:35
-
@brianlmerritt Developers would be better to not use Flash at all these days. – Brad Oct 23 '17 at 18:11
-
-
@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. – Brad Oct 23 '17 at 22:50
-
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... – brianlmerritt Oct 25 '17 at 07:14
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

denislexic
- 10,786
- 23
- 84
- 128
-
7As 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 Apr 18 '11 at 16:38
-
2@david I disagree with you. You can see its reputation over the internet. W3schools is really good for HTML/CSS information. – Muhammad Imran Tariq Apr 18 '11 at 17:12
-
4@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: http://meta.stackexchange.com/questions/87678/discouraging-w3schools-as-a-resource – David Apr 18 '11 at 17:19
-
-
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? – Bitterblue Dec 03 '14 at 09:18
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.

Noufal Ibrahim
- 71,383
- 13
- 135
- 169