SWFObject 2.2 and Safari Gotcha

Posted by Kristofer Joseph Fri, 22 Jan 2010 18:32:39 GMT

When setting the style class attribute using dynamic embedding with SWFObject, Safari will throw a parse error and not embed your Flash file. You need to use object bracket notation instead of dot notation.

Example: foo["pantyhose"] instead of foo.pantyhose

<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <script type="text/javascript" src="assets/js/swfobject.js"></script>
    <script type="text/javascript">
        var flashvars = {};
        flashvars.event = "%2fevent_guid_1%2f";
        var params = {};
        var attributes = {};
        attributes["class"] = "flashcontent";
        attributes.id = "FlashContent";
        swfobject.embedSWF("yourHappySWF.swf", "alternativeContent", "100%", "100%", "9.0.0", false, flashvars, params, attributes);
    </script>
    <style type="text/css" media="screen"> 
        html, body  { height:100%; }
        body { margin:0; padding:0; overflow:auto; text-align:center; }   
        #flashcontent { display:none; }
    </style>
</head>

no comments | atom

Comments

Leave a response

Leave a comment