I've got a bit of an awkward scenario here and this is going to be a hack, but I am out of options, so please bear with me. I have a third party web application that has content holders embedded on its main page. Inside a content holder, you have the ability to specify your own and Javascript. This is the only place I can make HTML/javascript edits. I do not have access to the rest of the page.
The project I am working on uses these content holders to host an iframe that points off to MyCustomWebPage. MyCustomWebPage has an "X-UA-Compatible" Meta tag on it. Unfortunately, since it is hosted in an iframe, the third party web application page settings seem to be overriding the settings on MyCustomWebPage. This means my "X-UA-Compatible" Meta tag is not functioning/being ignored/etc.
As a result, I am wondering if it is feasible to append an "X-UA-Compatible" Meta tag to the third party web application's element when the content holder loads. It does not currently have an "X-UA-Compatible" Meta tag. I found the following example about how to append a meta tag from another stackoverflow post.
In my content holder I now have the following:
<script language="javascript">
//<![CDATA[
function metafix() {
var iefix=document.createElement('meta');
iefix.setAttribute("http-equiv", "X-UA-Compatible");
iefix.setAttribute("content", "IE=9");
var x = document.getElementsByTagName('head')[0];
alert(x);
document.getElementsByTagName('head')[0].appendChild(iefix);
}
metafix();
//]]>
</script>
<iframe style="WIDTH: 100%; HEIGHT: 515px" id="MyCustomWebPage" src="www.mycustomwebpage.web" width="100%"></iframe>
The CDATA tags were automatically inserted by the third party web application's content editor. Now, I know this code is executing, because when the page loads, I see the alert(x). It says object, so I know it is finding the element. The problem is, "X-UA-Compatible" Meta tag refuses to append to the element. Doing a "View Source" confirms this. It's like the appendChild(iefix) never executes.
Why is this happening and what can I do to force that code to execute, so the tag gets appended to the third party web application's element?