How do you embed a SWF file in an HTML page?
Join Stack Overflow to learn, share knowledge, and build your career.
|
The best approach to embed a SWF into an 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 an 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:
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. It Is highly recommended and very simple to use. |
|||||||||||||||||||||
|
|
|||||||||||||||||||||
|
|
This is suitable for application from root environment.
Additional parameters should be/can be added which depends on .swf it self. No embed, just object and parameters within, so, it remains valid, working and usable everywhere, it doesn't matter which !DOCTYPE is all about. :) |
|||
|
|
|
If you are using one of those js libraries to insert Flash, I suggest adding plain object embed tag inside of |
|||||
|
|
|||||||||
|
|
How about simple HTML5 tag embed?
|
|||||
|
|
I use http://wiltgen.net/objecty/, it helps to embed media content and avoid the IE "click to activate" problem. |
|||||
|
|
As mentioned SWF Object is great. UFO is worth a look as well |
|||
|
|
|
What is the 'best' way? Words like 'most efficient,' 'fastest rendering,' etc. are more specific. Anyway, I am offering an alternative answer that helps me most of the time (whether or not is 'best' is irrelevant). Alternate answer: Use an iframe. That is, host the SWF file on the server. If you put the SWF file in the root or public_html folder then the SWF file will be located at Then, on your index.html or wherever, link the above location to your iframe and it will be displayed around your content wherever you put your iframe. If you can put an iframe there, you can put an SWF file there. Make the iframe dimensions the same as your SWF file. In the example below, the SWF file is 500 by 500. Pseudo code:
The line of HTML code above will embed your SWF file. No other mess needed.
Pros: W3C compliant, page design friendly, no speed issue, minimalist approach. That is an alternate answer. Whether it is the 'best' answer depends on your project. |
|||||||||||||
|
|
This one will work, I am sure!
|
||||
|
|
|
You can use JavaScript if you're familiar with, like that:
--the 9.0.0 is the flash version. Or you can use the |
|||||||||||||||||||||
|
|
This worked for me:
|
|||
|
|
protected by Community♦ May 23 '14 at 17:23
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?