0

I have a main page that include a javascript that was creating an iframe dynamically same below:

<script>
 document.domain = "mydomain.com"
 var iframe = document.createElement("iframe");
 document.body.appendChild(iframe);
 // creating other element in ifram dynamically 
</script>

But in IE I kept receiving a security warning because of document.domain = "mydomain.com" (I need document.domain and I can not remove it).

I found a solution for IE8. this is the solution :

var u = 'javascript:(function(){document.open();document.domain="mydomain.com";document.close();})()';
iframe.src = u;

But it does not work on IE6. Is there any solution for my problem?

Note: I want to create other element in iframe by script and I want to load the content of iframe by src.

James A Mohler
11.1k15 gold badges50 silver badges76 bronze badges
asked Aug 7, 2011 at 11:12

1 Answer 1

1

Create the iFrame using innerHTML.

Write the full HTML for the iFrame including the SRC attribute. Then find your element and set innerHTML to the string with the iFrame source.

answered Aug 7, 2011 at 11:19
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.