javascripthtmlflashswfobject

I need help to add a swf in my site - swfobject


I need some help to implement swfobject.

I add this to my page:

<script src="https://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js" src_type="url" />

then I create a div with ID: flash-banner

<div id="flash-banner"></div>

and this is how I try to call the swfobject

<script>
var flash = document.getElementById("#flash-banner");
swfobject.embedSWF("pub/media/wysiwyg/welcome.swf", flash, 300, 120, 10);
</script>

I do something wrong? What is not good here?

Thank you


Solution

  • As mentioned, no one should be doing anything new with Flash these days - it's a dead end technology (I don't have it installed in any of my browsers, on any platform, for example). But the technical problem is that embedSWF wants the name of the ID as a string, but document.getElementByID returns the object, not its name. So, what you want is simply:

    <script>
    swfobject.embedSWF("pub/media/wysiwyg/welcome.swf", "flash-banner", "300", "120", "10");
    </script>