I have some existing code that I have been tasked with upgrading to a valid doctype of HTML4.01 strict.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

In the code I've come across an <iframe>, and this does not sit well with the w3 validator.

      OnLoad="javascript: LoadAddAttachmentiFrame('Stock-Attachment-135','/cgi-bin/Xebra?UploadAttachment&amp;s=gnfhcjt7&amp;itemIdentifier=Stock-Attachment-135','gnfhcjt7');" 

The w3 validator even seems to claim that <iframe> is not included the html 4.01 strict doctype.

Now I've been to another website where they claim that there is infact another way to embed content within another document. Unfortunately it requires that you use two different methods (one for IE and one for all other browsers); IE uses an ActiveX Object, and the rest of the browsers use an <object> tag. Additionally the site seems to be refering to an xhtml doctype and not the html 4.01 strict doctype that I am referring to myself.

I don't know what the correct way to embed this content into my html 4.01 strict doctype would be, and additionally I'm concerned that the Javascript that is meant to be called in the onload attribute of the <iframe> tag will not work with the methods suggested in the website; using the ActiveX control for IE and <object> tag for all other browsers.

2 answers

Rob 230

Well, there is no "onload" (lower case) attribute for iframe so forget that. I would have thought 'object' would work in IE8 at least.

Answered over 8 years ago by Rob
o.k.w 2355

W3C has another doctype decalration for documents with frames or iFrames.

Check out W3C's Introduction to frames

The declaration is:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"

For supported iframe attributes, see Inline frames: the IFRAME element

Answered over 8 years ago by o.k.w
  • That doctype doesn't allow for the body tag. Am I missing something here? Andrew J. Leer over 8 years ago
  • No. The frameset doctype is ONLY for full framesets, not ordinary documents with iframes. Basically, <object> is the only way to embed external objects in strict-doctype pages. If you want to use iframe, applet or embed, you need to use a transitional doctype. A pox on IE for making life difficult once again. Richard Grevers over 8 years ago
  • @Richard, Yea you are right. I have no idea why iFrame is mentioned inside the W3C doc tho. o.k.w over 8 years ago
  • @Andrew: body tag is not allowed because as Richard commented, this is for frameset only. This is not what you need. Apology. o.k.w over 8 years ago
  • @o.k.w. What can I use instead given this doctype? Andrew J. Leer over 8 years ago
  • @Andrew, this doctype is for frameset, not suitable for your iFrame need. If you really need "HTML 4.01 strict", iFrame will not be usable. My recommendation is to use transitional. iFrame is still supported in all popular browsers. o.k.w over 8 years ago