<iframe> - can I change DOCTYPE

I

icogs

If I have an <iframe> element with a src attribute set to
"somedoc.xml" then, as expected, the iframe.contentDocument.doctype
matches the source file.

If I do not specify a src document I get, in Firefox at least,
about:blank loaded which is a vanilla html document.

Say I want to create the contents of the <iframe> document entirely
programmatically and the default html document is not appropriate. Can
I somehow specify the appropriate DOCTYPE ?

I have a work-around whereby I set the src attribute to a skeleton
document, but this is not ideal.
 
G

gimme_this_gimme_that

This might give you a start - it's untested ...

<iframe id="my_frame" name="my_frame" DOCTYPE=""/>
<script language="JavaScript">
var iframe = document.getElementById('my_frame');
iframe.DOCTYPE="text/html";
// to add content to the iframe try:
var text_node = document.createTextNode('hello world');
iframe.appendChild(iframe);
</script>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top