Robert
Robert

Reputation: 812

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

Upvotes: 0

Views: 412

Answers (2)

Chris
Chris

Reputation: 1174

swfobject should be avoided because it no longer works in Chrome.

More details in this answer: swfobject.embedSWF not working?

Upvotes: 0

MisterNeutron
MisterNeutron

Reputation: 3359

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>

Upvotes: 2

Related Questions