I have the following javascript code (at bottom) that I inject per api call for clients from their published websites.
Clients within their web page make a script tag call such as:
<div id="myDivID"/>
<script type="text/javascript" src="http//:srv.ab.com/api/getswf?divIdToReplace=myDivID"></script>
Once that is executed the following code is injected from the api call and replaces the div with a swf:
<script type="text/javascript">
(function () {
var object = document.createElement('object');
object.setAttribute('width', '300');
object.setAttribute('height', '250');
object.setAttribute('classid', 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000');
var param1 = document.createElement('param');
param1.setAttribute('name', 'movie');
param1.setAttribute('value', 'http://srv.ab.com/test.swf');
var embed = document.createElement('embed');
embed.setAttribute('src', 'http://srv.ab.com/test.swf');
embed.setAttribute('width', '300');
embed.setAttribute('height', '250');
var param2 = document.createElement('param');
param2.setAttribute('name', 'wmode');
param2.setAttribute('value', 'transparent');
object.appendChild(param1);
object.appendChild(embed); // <-- Invalid argument for IE9!!!
object.appendChild(param2);
var container = document.getElementById('myDivID');
while (container.firstChild) { container.removeChild(container.firstChild); }
container.appendChild(object);
})();
</script>
However, the swf doesn’t display in IE9 but renders fine in Chrome and FF.
One thing to note is the invalid argument error for IE9 only in the console that I’m getting as called out below in the script.
What am I missing here? I can’t use jquery/swfobject as it has to be plain javascript that I inject into the client page.
Turns out IE sets certain intranet/internet sites to Quirks mode. This causes IE9 to use IE6 javascript behavior and IE7 DOM manipulation.
Adding the following meta data in the header alleviates this:
However, from an api delivery solution the X-UA-Compatible header can be set in the response with value of IE=edge.