Take a moment to review the correct answer provided in this article. It seems like that could be the root of your problem.
If not, consider trying out this quick workaround I came across on another post.
var frame = $('<iframe>')
.attr('id', 'myIframe')
.addClass('someClass')
.attr('src', 'javascript:(function () {' +'document.open();document.domain=\'myDomain.net\';document.close();' + '})();');
.appendTo($('#someDiv'));
Additionally, you may find some insights in this external resource link.
In response to your comment, it appears that the JavaScript function is setting the document domain rather than assigning the source, which might not be correctly executed in Internet Explorer.
For further examples and explanations, refer to this source.
You can try implementing something like the following...
var wrapUpIframe = document.createElement("iframe");
wrapUpIframe.id = 'WrapUpDialog3';
wrapUpIframe.src = setSrc();
document.body.appendChild(wrapUpIframe);
function setSrc(){
document.open();
document.domain='dc.com';
document.close();
return 'WrapUpDialog.html';
}
Adjust as needed to ensure the URL for the iframe is returned after setting the document domain. This approach may work for your situation based on my observations.
While my experience with a similar issue may not directly solve your problem, adjusting the function that sets the document domain helped me bypass the access denied error.
To further align domains, you can include the following script in your main document.
<script type="text/javascript">
document.domain = 'dc.com';
</script>
I also recommend checking this informative resource for an explanation on explicitly setting the document domain, which proved beneficial in my past experiences. Notably, consider this quote...
Explicitly setting the value indicates intent to "cooperate" with a script on another subdomain (under the same parent domain).
Lastly, if timing is a concern, you could address it using code like this snippet that ensures the iframe is loaded before accessing contentWindow.
var iframe = document.createElement("iframe");
iframe.src = "WrapUpDialog.html";
if (iframe.attachEvent){
iframe.attachEvent("onload", function(){
alert("Local iframe is now loaded.");
});
} else {
iframe.onload = function(){
alert("Local iframe is now loaded.");
};
}
document.body.appendChild(iframe);
var iframeWindow = iframe.contentWindow || iframe.contentDocument.parentWindow;