Using FCKEditor to embed Flash content; does not appear in IE
April 3rd, 2009
No comments
This is because FCKEditor only create a <embed> element to display Flash content which does not work for IE. IE requires the <object> element to embed Flash in a webpage where else <embed> only works for Firefox based browsers. This links shows the way to embed Flash object in HTML.
Changing the JavaScript code in FCKEditor is a bit troublesome (my JavaScript skill is not good enough) So if you are using .NET you can refer to this method I created to wrap the <embed> element with <object> element. This is more of a quick hack so I make no guarantee it will work in your environment. I am using LINQ to XML for this so you will need Visual Studio 2008 + .NET 3.5.
Public Function UpdateEmbedTag(ByVal content As String) As String Const embedTag As String = "<embed " Const objectTag As String = _ "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'" + _ "codebase='http://download.macromedia.com/pub/shockwave/cabs/" + _ "flash/swflash.cab#version=6,0,40,0' id='myMovieName'><embed " Const embedCloseTag As String = "</embed>" Const objectCloseTag As String = "</embed></object>" '<embed type="application/x-shockwave-flash" ' pluginspage="http://www.macromedia.com/go/getflashplayer" ' src="http://localhost:49427/userfiles/Video/test/flash.swf" ' play="true" loop="true" menu="true"></embed> ' 'TO ' '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ' codebase="http://download.macromedia.com/pub/shockwave/cabs/ ' flash/swflash.cab#version=6,0,40,0" id="myMovieName"> ' <param name="movie" value=""/> '</object> Dim _newContent = "<div>" + content.Replace(" ", " ") + "</div>" _newContent = _newContent.Replace(embedTag, objectTag) _newContent = _newContent.Replace(embedCloseTag, objectCloseTag) Dim root = XElement.Parse(_newContent) Dim embedElementList = root.Descendants("embed") Dim flashLocation As String Dim height As String Dim width As String If embedElementList.Count > 0 Then For Each embedElement As XElement In embedElementList If ((embedElement.Attribute("pluginspage") = _ "http://www.macromedia.com/go/getflashplayer") _ Or embedElement.Attribute("type").ToString.Contains("flash")) Then flashLocation = embedElement.Attribute("src") height = embedElement.Attribute("height") width = embedElement.Attribute("width") If Not String.IsNullOrEmpty(width) Then _ embedElement.Parent.Add(New XAttribute("width", width)) If Not String.IsNullOrEmpty(height) Then _ embedElement.Parent.Add(New XAttribute("height", height)) Dim movie = New XElement("param") movie.Add(New XAttribute("name", "movie")) movie.Add(New XAttribute("value", flashLocation))
embedElement.Parent.Add(movie)
End If Next Return root.ToString Else Return content End If End Function
Categories: Uncategorized .NET 3.5, fckeditor, flash, ie, internet explorer, LINQ to XML, Visual Studio 2008