How to Embed a Swf File in an HTML Page

How to embed a SWF file in an HTML page?

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:

<!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>

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.

Embed Local .swf File in HTML

Use embed in your HTML code :

<embed src="myFile.swf"  height="800px" width="600px">

source tutorial: html5 embed flash element

How to embed a swf file into html code?

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>

Embedding SWF file in HTML5 - How to add alternative content?

Use the object tag instead of the embed tag like so:
<object width="550" height="400" data="main.swf">Alertnative Content Here</object>

See: EMBED vs. OBJECT

What's the ultimate way to embed Flash (swf) files to HTML (and XHTML) documents?

Here it is:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title></title>
<script type="text/javascript" src="swfobject.js"> </script>
<script type="text/javascript">
swfobject.embedSWF('test.swf', 'myFlash', '320', '240', '9.0.0', '/swfobject/expressInstall.swf', 0, 0, 0);
</script>
</head>
<body>
<div>
<object id="myFlash" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="320" height="240">
<param name="movie" value="test.swf">
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="test.swf" width="320" height="240">
<!--<![endif]-->
<p>Version ???</p>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</div>
</body>
</html>
  • I combine the static and dynamic methods of SWFObject
  • The static part is using the nested-objects method

What is the best way to embed swf into html page

You can try swfobject: https://github.com/swfobject/swfobject.
It`s very simple to add Flash and Flashvars.

Here with 100%:
http://learnswfobject.com/advanced-topics/100-width-and-height-in-browser/

swfobject.embedSWF("test.swf", "flashContent", "100%", "100%", "9.0.0", false, flashvars, params, attributes);

How to embed a swf file and link it to another page using HTML?

<div onmousedown="window.location.href='new_location'">
<object>
<param name="movie" value="3.swf">
<param name="wmode" value="transparent" />
<embed wmode=transparent allowfullscreen="true" allowscriptaccess="always" src="3.swf"></embed>
</object>
</div>


Related Topics



Leave a reply



Submit