Software4me

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Inserting A Flash Movie in XHTML, Avoding the use of <embed> tags.
Noele
post Aug 29 2009, 03:58 AM
Post #1


Contributer
***

Group: Root Admin
Posts: 76
Joined: 14-September 06
From: United Kingdom (East Midlands)
Member No.: 1



If you have ever needed to insert a Flash movie into a web page, and found your page code will not validate afterwards because the <embed> tags are not supported under XHTML there are ways around it.

Here and example of inserting Flash into HTML using <embed> tags

CODE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="468" height="60">
   <param name="movie" value="Untitled-1.swf">
   <param name="quality" value="high">
   <embed src="Untitled-1.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="468" height="60"></embed>
</object>
</body>
</html>


Internet Explorer does not use the the code inside the <embed> </embed> tags but other browsers, such as Mozilla, Firefox etc can.

This is not an ideal solution however. If we took the same code and converted it into XHTML, our page would not validate. There is no <embed> in any current versions of XHTML

Of course you could use JavaScript to deliver the relevant code on a browser specific basis but it can get rather messy. Here is an alternative method which will validate in XHTML.

CODE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase= "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="200" height="200">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="movie_name.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#FFFFFF" />
<!--[if !IE]> <-->
    <object data="movie_name.swf" width="200" height="200" type="application/x-shockwave-flash">
     <param name="quality" value="high" />
     <param name="bgcolor" value="#FFFFFF" />
     <param name="pluginurl" value="http://www.macromedia.com/go/getflashplayer" />
     <a href="http://www.macromedia.com/go/getflashplayer">Get Flash Player</a>
    </object>
<!--> <![endif]-->
</object>

</body>
</html>


You will notice that everything is duplicated. This is because Internet Explorer interprets things differently so will use the first set of parameters. The <!--[if !IE]> translates into "IF NOT Internet Explorer" and so the code between <!--[IE]> and [!endfif]--> is ignored by IE but is executed by other browser types.

Note too that under XHTML all tags must have a closure. This can seem confusing but in essence if a tag has two elements, such as <body> and </body> the second tag has the closure. If the tag is a single element, such as an image a closing tag must be added - represented by a space and a back slash - before the final >

Examples:
CODE
<img src="image.gif" width="100, height="100" alt="Image description"> <!--Bad-->
<img src="image.gif" width="100, height="100" alt="Image description" /><!--Good-->


With more and more devices accessing the web, code validation will become ever more important in the future. So if you want your web-pages to be cross platform compatible, always validate them.

XHTML can be unforgiving and a simple error can cost you dearly.

Go to the top of the page
 
+Quote Post
NonsHaileania
post Apr 9 2011, 06:58 PM
Post #2


Newbie
*

Group: Members
Posts: 5
Joined: 14-January 11
From: Spain
Member No.: 907



You just have to grab HTML code Youtube provide, and paste it to your website on the desired spot.

Thats it.
Go to the top of the page
 
+Quote Post
Noele
post Apr 10 2011, 03:46 AM
Post #3


Contributer
***

Group: Root Admin
Posts: 76
Joined: 14-September 06
From: United Kingdom (East Midlands)
Member No.: 1



QUOTE (NonsHaileania @ Apr 9 2011, 07:58 PM) *
You just have to grab HTML code Youtube provide, and paste it to your website on the desired spot.

Thats it.

This is true but what if you wished to resize the Flash video to fit your HTML page or to pass it parameters from the HTML page? uTube code snippets often use JavaScript, which is fine if the users browser is set to allow JS. If not, no video. In linking directly to uTube you are also giving them a one-way link from your site. Some security options can also block 3rd party video streaming so don't think everyone could see it just because you can in your browser.

Flash movies are often more interactive than the videos offered by uTube.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



Software4me
RSS Lo-Fi Version Time is now: 23rd April 2014 - 09:17 PM