swfobject IE6 error

by graham

Error: 'null' is null or not an object

swfobject IE6 error

Wow, this was fun to figure out. IE6 doesn’t like hyphens in the id of the target element. Running the following code displayed the flash fine in IE6 (and other browsers) but there was an error coming from swfobject.js (line 14 actually had jQuery on which helpfully sent me down the wrong path in debugging the error). 

var flashvars = { assetPath:'<%=ResolveUrl("~/") %>assets/flash/generic/assets/', };

var params = { wmode: "transparent" };

var attributes = {};

swfobject.embedSWF('<%=ResolveUrl("~/") %>assets/flash/generic/carousel.swf', "flash-carousel", '100%', '422', '9.0.0', false, flashvars, params, attributes);

 

Changing flash-carousel to flashcarousel stopped the error. 

 

var flashvars = { assetPath:'<%=ResolveUrl("~/") %>assets/flash/generic/assets/', };

var params = { wmode: "transparent" };

var attributes = {};

swfobject.embedSWF('<%=ResolveUrl("~/") %>assets/flash/generic/carousel.swf', "flashcarousel", '100%', '422', '9.0.0', false, flashvars, params, attributes);

 

So make sure you don't use hyphens in your flash container ids. 

Comments are closed