View Full Version : insert div and flash into body

01-12-2007, 02:07 PM
Hi, i am trying to insert a div with a flash object inside into a page. but would really like to do it in a dom proper way. i have this code so far:

var sCreative='<div id="hockeystick"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="100%" height="100%"><param name="movie" value="http://www.dqatestsite.nl/test/hockeystick.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="SCALE" value="exactfit" /><embed src="http://www.dqatestsite.nl/test/hockeystick.swf" width="100%" height="100%" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" scale="exactfit"></embed></object></div>';
document.body.innerHTML = document.body.innerHTML + sCreative;

this is some very messy code, but i did not know where to begin at first so i justed started trying some stuff. Does anybody know a proper way to do this?

01-12-2007, 05:55 PM
Yes. Check out SWFObject.


It was created to solve (among other things) exactly this issue. All you do is make a div tag with html, and then use a line or two of javascript to write the flash object into it. Once you use it, you will never go back. See my website for examples of how this is done:

www.trippertreats.com (http://www.trippertreats.com)

After reading that link above (SWFObject), you will have downloaded a .js file and included it in your header. Then, all you would have to do in your case is this:

<div id="hockeystick"></div>
var swfHockey = new SWFObject("http://www.dqatestsite.nl/test/hockeystick.swf", "hockey", 100%, 100%, 7, #000000);
</script>Let me know how this works out for you and if you have any other questions about it. As you can see, it's much simpler. For additional options, check out


Happy Flashing,

01-15-2007, 10:40 AM
Ah, yes, thanks a lot. this totally works out for me! thank you!