Notice: Undefined index: HTTP_REFERER in C:\Domains\patricky\\wwwroot\index.php on line 3 .NET 3.5 « Patrick’s Bytes

Patrick’s Bytes

Techie for the past 30 years…

Using FCKEditor to embed Flash content; does not appear in IE

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='" + _
    "flash/,0,40,0' id='myMovieName'><embed "
    Const embedCloseTag As String = "</embed>"
    Const objectCloseTag As String = "</embed></object>"

    '<embed type="application/x-shockwave-flash" 
    '  pluginspage="" 
    '  src="http://localhost:49427/userfiles/Video/test/flash.swf" 
    '  play="true" loop="true" menu="true"></embed>
    '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
        '  codebase="
        ' flash/,0,40,0" id="myMovieName">
    '  <param name="movie" value=""/>

    Dim _newContent = "<div>" + content.Replace("&nbsp;", " ") + "</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") = _
              "") _
           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))
         End If

      Return root.ToString

      Return content
    End If

  End Function