Javascript – Flash content replacing with javascript document.getElemendByID(“id”).innerHTML

ajaxflashhtmljavascript

I have a webpage, on which I am using Ajax to replace different divs of my page against some click events.. All works fine for regular HTML… but when I want to add a SWF object tag through function

document.getElementByID("div-id").innerHTML = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000> .... All flash movie code ... </object>";

My browser shows nothing.. and no error is generated also… I am assuming that it should show the Flash movie.. I have checked it in IE 8.0, FireFox, Chrome.. none of them is working.. I have monitored the div using firebug, it is showing that div is being replaced by the Flash player code, but then why it is not being displayed in that div?

Best Answer

The problem may be hidden in the All flash movie code part... :P Flash embedding is tricky, there is many different way to embed it leading to different result. That's why ppl use libraries instead of writing plain html/js.

The most popular and standard way to embed Flash is to use swfObject. Or you use jQuery, there is flashembed from jQuery Tools.

Both of them works in all major browsers, able to handle things like flashVars, embed params etc.