How do you 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.
<object width="100" height="100">
<param name="movie" value="file.swf">
<embed src="file.swf" width="100" height="100">
</embed>
</object>
How about simple HTML5 tag embed?
<!DOCTYPE html>
<html>
<body>
<embed src="anim.swf">
</body>
</html>
This is suitable for application from root environment.
<object type="application/x-shockwave-flash" data="/dir/application.swf"
id="applicationID" style="margin:0 10px;width:auto;height:auto;">
<param name="movie" value="/dir/application.swf" />
<param name="wmode" value="transparent" /> <!-- Or opaque, etc. -->
<!-- ↓ Required paramter or not, depends on application -->
<param name="FlashVars" value="" />
<param name="quality" value="high" />
<param name="menu" value="false" />
</object>
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 <noscript/>.
<object type="application/x-shockwave-flash" data="http://www.youtube.com/v/VhtIydTmOVU&hl=en&fs=1&color1=0xe1600f&color2=0xfebd01"
style="width:640px;height:480px;margin:10px 36px;">
<param name="movie" value="http://www.youtube.com/v/VhtIydTmOVU&hl=en&fs=1&color1=0xe1600f&color2=0xfebd01" />
<param name="allowfullscreen" value="true" />
<param name="allowscriptaccess" value="always" />
<param name="wmode" value="opaque" />
<param name="quality" value="high" />
<param name="menu" value="false" />
</object>
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
This one will work, I am sure!
<embed src="application.swf" quality="high" pluginspage="http://www.macromedia.com/go/getfashplayer" type="application/x-shockwave-flash" width="690" height="430">
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 www.YourDomain.com/YourFlashFile.swf.
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:
<iframe src="//www.YourDomain.com/YourFlashFile.swf" width="500" height="500"></iframe>
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.
Cons: White space around your SWF file when launched in a browser.
That is an alternate answer. Whether it is the 'best' answer depends on your project.
I know this is an old question. But this answer will be good for the present.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>histo2</title>
<style type="text/css" media="screen">
html, body { height:100%; background-color: #ffff99;}
body { margin:0; padding:0; overflow:hidden; }
#flashContent { width:100%; height:100%; }
</style>
</head>
<body>
<div id="flashContent">
<object type="application/x-shockwave-flash" data="histo2.swf" width="822" height="550" id="histo2" style="float: none; vertical-align:middle">
<param name="movie" value="histo2.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffff99" />
<param name="play" value="true" />
<param name="loop" value="true" />
<param name="wmode" value="window" />
<param name="scale" value="showall" />
<param name="menu" value="true" />
<param name="devicefont" value="false" />
<param name="salign" value="" />
<param name="allowScriptAccess" value="sameDomain" />
<a href="http://www.adobe.com/go/getflash">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
</a>
</object>
</div>
</body>
</html>
Thi works on IE, Edge, Firefox, Safari and Chrome.
<object type="application/x-shockwave-flash" data="movie.swf" width="720" height="480">
<param name="movie" value="movie.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#000000" />
<param name="play" value="true" />
<param name="loop" value="true" />
<param name="wmode" value="window" />
<param name="scale" value="showall" />
<param name="menu" value="true" />
<param name="devicefont" value="false" />
<param name="salign" value="" />
<param name="allowScriptAccess" value="sameDomain" />
<a href="http://www.adobe.com/go/getflash">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
</a>
</object>
This worked for me:
<a target="_blank" href="{{ entity.link }}">
<object type="application/x-shockwave-flash" data="{{ entity.file.path }}?clickTAG={{ entity.link }}" width="120" height="600" style="visibility: visible;">
<param name="quality" value="high">
<param name="play" value="true">
<param name="LOOP" value="false">
<param name="wmode" value="transparent">
<param name="allowScriptAccess" value="true">
</object>
</a>
Use the <embed> element:
<embed src="file.swf" width="854" height="480"></embed>
You can use JavaScript if you're familiar with, like that:
swfobject.embedSWF("filename.swf", "Title", "width", "height", "9.0.0");
--the 9.0.0 is the flash version.
Or you can use the <object> tag of HTML5.
Related
I am working on a html project with video, and need to work with this video. I am hoping to apply two style
width: 550px;
controls preload="auto;
but am not sure where to place it. I need the video to preload due to its long loading time! Code examples have always shown a tag, but this code does not have any.
<object id="flashObj" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,47,0">
<param name="movie" value="http://c.brightcove.com/services/viewer/federated_f9?isVid=1&isUI=1" />
<param name="bgcolor" value="#FFFFFF" />
<param name="flashVars" value="videoId=3286763175001&linkBaseURL=http%3A%2F%2Fmedianetwork.oracle.com%2Fvideo%2Fplayer%2F3286763175001&playerID=1787102915001&playerKey=AQ~~,AAAAAFcSbzI~,OkyYKKfkn3xPOduPEsqhjskdCvDxqymz&domain=embed&dynamicStreaming=true" />
<param name="base" value="http://admin.brightcove.com" />
<param name="seamlesstabbing" value="false" />
<param name="allowFullScreen" value="true" />
<param name="swLiveConnect" value="true" />
<param name="allowScriptAccess" value="always" />
<embed src="http://c.brightcove.com/services/viewer/federated_f9?isVid=1&isUI=1" bgcolor="#FFFFFF" flashVars="videoId=3286763175001&linkBaseURL=http%3A%2F%2Fmedianetwork.oracle.com%2Fvideo%2Fplayer%2F3286763175001&playerID=1787102915001&playerKey=AQ~~,AAAAAFcSbzI~,OkyYKKfkn3xPOduPEsqhjskdCvDxqymz&domain=embed&dynamicStreaming=true" base="http://admin.brightcove.com" name="flashObj" width="640" height="358" seamlesstabbing="false" type="application/x-shockwave-flash" allowFullScreen="true" allowScriptAccess="always" swLiveConnect="true" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" style="width: 550px;"></embed>
</object>
If someone could please shorten and explain what some of the essential tags do that would be greatly appreciated.
id is the element of the video, the param tag helps to define the plugins with the element, http://www.w3schools.com/tags/tag_param.asp , this gives a good example.
I am coding interactive short story and and embedded my Flash into my HTML page but it is not playing at all. It's just a black screen. The animation plays fine when using Safari though.
Help would be welcome ASAP.
This is the code I used to embed the swf file:
<div id="sleepingvideo">
<object width="720" height="510">
<param name="movie" value="SC_Flash.swf" />
<param name="allowfullscreen" value="true" />
<param name="scale" value="noScale" />
<param name="salign" value="lt" />
<param name="allowscriptaccess" value="always" />
<param name="flashvars" value="path=deuter" />
<embed margin-height="100" width="600" height="400" src="survey.swf"
flashvars="path=deuter" allowfullscreen="true"
allowscriptaccess="always" name="player1" scale="noScale"
salign="lt"></embed>
</object>
</div>
I advice you to use SWFObject for flash embedding. It works everywhere.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
There is one html page that contains only a .swf file that can be streaming from there:
http://tvoy-start.ru/uroki/1nedel/1nedel.html
Here is that page source:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- saved from url=(0014)about:internet -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<!-- saved from url=(0025)http://www.techsmith.com/ -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="DC.date" content="2011-09-15 11:37:43 " />
<meta name="DC.language" content="ENU" />
<meta name="DC.title" content="1nedel" />
<title>Создано Camtasia Studio 6</title>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
swfobject.registerObject("csSWF", "9.0.115", "expressInstall.swf");
</script>
<style type="text/css">
body
{
background-color: #1a1a1a;
font: .8em/1.3em verdana,arial,helvetica,sans-serif;
text-align: center;
}
#media
{
margin-top: 40px;
}
#noUpdate
{
margin: 0 auto;
font-family:Arial, Helvetica, sans-serif;
font-size: x-small;
color: #cccccc;
text-align: left;
width: 210px;
height: 200px;
padding: 40px;
}
</style>
</head>
<body>
<div id="media">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="900" height="420" id="csSWF">
<param name="movie" value="1nedel_controller.swf" />
<param name="quality" value="best" />
<param name="bgcolor" value="#1a1a1a" />
<param name="allowfullscreen" value="true" />
<param name="scale" value="showall" />
<param name="allowscriptaccess" value="always" />
<param name="flashvars" value="autostart=false&thumb=FirstFrame.png&thumbscale=45&color=0x1A1A1A,0x1A1A1A" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="1nedel_controller.swf" width="900" height="420">
<param name="quality" value="best" />
<param name="bgcolor" value="#1a1a1a" />
<param name="allowfullscreen" value="true" />
<param name="scale" value="showall" />
<param name="allowscriptaccess" value="always" />
<param name="flashvars" value="autostart=false&thumb=FirstFrame.png&thumbscale=45&color=0x1A1A1A,0x1A1A1A" />
<!--<![endif]-->
<div id="noUpdate">
<p>The Camtasia Studio video content presented here requires a more recent version of the Adobe Flash Player. If you are you using a browser with JavaScript disabled please enable it now. Otherwise, please update your version of the free Flash Player by downloading here.</p>
</div>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</div>
<!-- Users looking for simple object / embed tags can copy and paste the needed tags below.
<div id="media">
<object id="csSWF" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="900" height="420" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0">
<param name="src" value="1nedel_controller.swf"/>
<param name="bgcolor" value="#1a1a1a"/>
<param name="quality" value="best"/>
<param name="allowScriptAccess" value="always"/>
<param name="allowFullScreen" value="true"/>
<param name="scale" value="showall"/>
<param name="flashVars" value="autostart=false"/>
<embed name="csSWF" src="1nedel_controller.swf" width="900" height="420" bgcolor="#1a1a1a" quality="best" allowScriptAccess="always" allowFullScreen="true" scale="showall" flashVars="autostart=false&thumb=FirstFrame.png&thumbscale=45&color=0x1A1A1A,0x1A1A1A" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>
</object>
</div>
-->
</body>
</html>
I wonder, where in the page's source, if it’s possible at all, can I find the link so that I could download that .swf file onto my computer?
Yes it's specified as "movie" param under object tag.
You can reach it at http://tvoy-start.ru/uroki/1nedel/1nedel_controller.swf
However, the swf file may have some server side control that doesn't allow you to see streaming if you aren't on that website. Just try.
EDIT: Forgot, you have to save the page, in my browser (firefox) is File->Save page with name
On internet explorer is the engine wheel icon->File->Save as
On other browsers, I don't know at the moment
So my basic understanding was that the <noscript> tag was used to display content if the user has scripting disabled, especially useful when there is no flash player.
So I am trying to figure out why in some code that was sent to me, that they have an <object> tag inside of the <noscript> tag...
<noscript>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="785" height="525" id="home" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="home.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /> <embed src="home.swf" quality="high" bgcolor="#ffffff" width="785" height="525" name="home" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="https://www.adobe.com/go/getflashplayer" />
</object>
</noscript>
Second part to my question is, can you put an image map in place of the flash player if scripting or flash has been disabled...
need to put an image map with two area coords:
<area shape="rect" coords="175,196,372,250"> <area shape="rect" coords="417,197,616,249">
The noscript element is designed to let you give alternate content (text) to users who have Javascript disabled.
<!DOCTYPE HTML>
<html>
<body>
<script type="text/javascript">
alert("Hello, world!");
</script>
<noscript>You have Javascript disabled.</noscript>
</body>
</html>
To provide alternate content for Flash, display the Flash using an object element, then embed another object element within it that contains the picture, like so:
<!DOCTYPE HTML>
<html>
<body>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab# version=6,0,40,0"
width="800" height="600">
<param name="movie" value="home.swf">
<object data="somePicture.png" type="image/png"></object>
</object>
</body>
</html>
I'm trying to position my Flex app so that its in the bottom 40% vertically, and the left 70% horizontally. This is how I define the flash section in CSS:
#flashContent { display:none;position:absolute; top:60%;width:70%;height:40%;}
Here is the HTML:
<div id="flashContent">
<p>
To view this page ensure that Adobe Flash Player version
10.0.0 or greater is installed.
</p>
<script type="text/javascript">
var pageHost = ((document.location.protocol == "https:") ? "https://" : "http://");
document.write("<a href='http://www.adobe.com/go/getflashplayer'><img src='"
+ pageHost + "www.adobe.com/images/shared/download_buttons/get_flash_player.gif' alt='Get Adobe Flash player' /></a>" );
</script>
<noscript>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="434" height="100%" id=app name>
<param name="movie" value=link_to_the_file />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="true" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data=link_to_the_file width="434" height="100%">
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="true" />
<!--<![endif]-->
<!--[if gte IE 6]>-->
<p>
Either scripts and active content are not permitted to run or Adobe Flash Player version
10.0.0 or greater is not installed.
</p>
<!--<![endif]-->
<a href="http://www.adobe.com/go/getflashplayer">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash Player" />
</a>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</noscript>
</div>
But it's still just appearing in the top-left corner. What am I doing wrong?
Thanks for reading.
Please don't use the values in percentage in flex. If you want to put your stuff in centre, then we have horizontalAlign and for vertically, we have verticalAlign properties.
Specify left, top, bottom and right in numbers only,