Search code examples
javascriptinternet-explorerswfobject

swfobject assigning a class - internet explorer error


I have a piece of PHP code that loops through to display all the banners that are stored in a database. If the code detects that the banner is a swf, it embeds it like this:

swfobject.embedSWF(\"".$banners->banner_url."\", \"flash_ad_con".$count."\", \"".$dimens['w']."\", \"".$dimens['h']."\", \"9.0.0\", false, false, false, {class: 'flash_ad_con'});

This works fine on all browsers except any version of Internet Explorer. If I remove the optional attributes that I add (in this case 'class') like this:

swfobject.embedSWF(\"".$banners->banner_url."\", \"flash_ad_con".$count."\", \"".$dimens['w']."\", \"".$dimens['h']."\", \"9.0.0\", false, false, false);

It then works on Internet Explorer but obviously doesn't have the class applied and is therefore out of alignment. I can't set the alignment using the ID as it's dynamic and I want to avoid changing the stylesheet to PHP if possible.

I think the reason it doesn't work in IE is that 'class' is a reserved word, but I'm using it within a JSON object so I didn't think it would be affected.

Does anyone have any workarounds or alternate ways of doing this? I would add it inline but as the DOM elements are being created at runtime, I can't really.

Thanks


Solution

  • Found the solution - using 'styleclass' instead of 'class' in the JSON object works across browsers. I couldn't find that anywhere in the official documentation, I found it under 'Issues' under their Google Code site