HEMANT SONKER’S BLOG

February 5, 2008

Validating Iframe

Filed under: HTML — Hemant Sonker @ 8:23 pm

As a developer ,i came across a solution for validating iframes in strict DTD. As iframe is a depreciated tag, still it works in html 4.01 ,xhtml1.0.But its better to use object in place of iframe.

<object> is for inserting any foreign object into XHTML documents. Since Iframes include HTML/XHTML documents, the MIME type for the document is “text/html” or “application/xhtml+xml”. We will use the first one because it is compatible with all browsers including Internet Explorer.

Let me show you by an example.

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” lang=”en” xml:lang=”en”>
<head>
<title></title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
</head>
<body>
<object style=”width:500px; height:200px” data=”http://www.google.com” type=”text/html” standby=”Google”></object>
</body>
</html>

Let me briefly explain the terms which are used in the above snippet.

  • classid - Defines a ClassID in the registry.
  • data – The URL of the object (required).
  • name – The name of the object if you are using it in JavaScript/VBScript or some other scripting language.
  • standby – Text to display when loading.
  • type – The MIME type of the object . Required.

When you run this example it is xhtml validated wheteher its transitional or strict.

No Comments Yet »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.