Home

Using IFRAME in DOCTYPE strict document

Taewook Kang

If you have an IFRAME element in a DOCTYPE strict document, HTML validators will not think the document as a valid DOCTYPE strict and throw an error. I've found a way to cheat these validators by using JavaScript's document.write.

<script type="text/javascript">
document.write(unescape("%3Ciframe src='http://google.com'%3E%3C/iframe%3E")) ;
</script>

Or if you insist on not cheating validators, you could use the following method. Although not intended, object tag can replace iframe in certain cases.

<!--[if IE]>
<object classid="clsid:25336920-03F9-11CF-8FD0-00AA00686F13" data="content.htm"></object>
<![endif]-->

<!--[if !IE]> <-->
<object type="text/html" data="content.htm"></object>
<!--> <![endif]-->