Patrioticcow
Patrioticcow

Reputation: 27038

how to, flash wont play on internet explorer?

i have a piece of flash that doesn't want to play in internet explorer:

    <div class="flash_slider">                   
           <object style="visibility: visible;" id="flashcontent" data="/files/theme/piecemakerNoShadow.swf" type="application/x-shockwave-flash" height="460" width="980">
                 <param value="transparent" name="wmode">
                   <param value="xmlSource=/files/theme/piecemakerXML.xml&amp;cssSource=/files/theme/piecemakerXML.css&amp;imageSource=/files/theme/" name="flashvars">
            </object>
                     <script type="text/javascript">
                       var flashvars = {};
                       flashvars.xmlSource = "/files/theme/piecemakerXML.xml";
                       flashvars.cssSource = "/files/theme/piecemakerXML.css";
                       flashvars.imageSource = "/files/theme/";
                       var attributes = {};
                       attributes.wmode = "transparent";
                       swfobject.embedSWF("/files/theme/piecemakerNoShadow.swf", "flashcontent", "980", "460", "10", "/files/theme/expressInstall.swf", flashvars, attributes);
                     </script>                       
                   </div>

any ideas? thanks

Upvotes: 0

Views: 576

Answers (1)

codeandcloud
codeandcloud

Reputation: 55200

Target IE using conditional comments.

<!--[if !IE] >
<script type = "text/javascript" >
    var flashvars = {};
    flashvars.xmlSource = "/files/theme/piecemakerXML.xml";
    flashvars.cssSource = "/files/theme/piecemakerXML.css";
    flashvars.imageSource = "/files/theme/";
    var attributes = {};
    attributes.wmode = "transparent";
    swfobject.embedSWF("/files/theme/piecemakerNoShadow.swf", "flashcontent", "980", "460", "10", "/files/theme/expressInstall.swf", flashvars, attributes); 
</script> 
<![endif]-->

As you are loading flash through SWFObject, it will ensure that your script won't run in IE.

Also try browser sniffing. ( Not recommended, but I dont see any other way here )

var isMSIE = /*@cc_on!@*/false;
if(!isMSIE){
    var flashvars = {};
    flashvars.xmlSource = "/files/theme/piecemakerXML.xml";
    flashvars.cssSource = "/files/theme/piecemakerXML.css";
    flashvars.imageSource = "/files/theme/";
    var attributes = {};
    attributes.wmode = "transparent";
    swfobject.embedSWF("/files/theme/piecemakerNoShadow.swf", "flashcontent", "980", "460", "10", "/files/theme/expressInstall.swf", flashvars, attributes);

}

If that does not work, try

var isMSIE = navigator.appName === 'Microsoft Internet Explorer';

This might help you: http://pipwerks.com/2011/05/18/sniffing-internet-explorer-via-javascript/

Upvotes: 1

Related Questions