IFrame Alternative – Recap!

18 Jan

I’m constantly amazed when I check my blog stats at how popular an old article I wrote on using Object tags as a replacement for an Iframe has become.  This is obviously an area that people are having trouble finding information, so here is a good starting place to find your solution:

First, my original posting – Alternative to < iframe />

And here are two examples, courtesy of W3C, on IFrame versus Object tag:

The basic IFrame example:

  <span class="kwrd">&lt;</span><span class="html">IFRAME</span> <span class="attr">src</span><span class="kwrd">="foo.html"</span> <span class="attr">width</span>=<span class="attr">400</span> <span class="attr">height</span>=<span class="attr">500</span><span class="kwrd">&gt;</span><br />  that unfortunately your user agent doesn't support. Alternatively you<br />  can get the related document <span class="kwrd">&lt;</span><span class="html">a</span> <span class="attr">href</span><span class="kwrd">="foo.html"</span><span class="kwrd">&gt;</span>here<span class="kwrd">&lt;/</span><span class="html">a</span><span class="kwrd">&gt;</span>.<br />  <span class="kwrd">&lt;/</span><span class="html">IFRAME</span><span class="kwrd">&gt;</span><br />

Becomes:

  <span class="kwrd">&lt;</span><span class="html">OBJECT</span> <span class="attr">data</span><span class="kwrd">="foo.html"</span> <span class="attr">width</span>=<span class="attr">400</span> <span class="attr">height</span>=<span class="attr">500</span><span class="kwrd">&gt;</span><br />  that unfortunately your user agent doesn't support. Alternatively you<br />  can get the related document <span class="kwrd">&lt;</span><span class="html">a</span> <span class="attr">href</span><span class="kwrd">="foo.html"</span><span class="kwrd">&gt;</span>here<span class="kwrd">&lt;/</span><span class="html">a</span><span class="kwrd">&gt;</span>.<br />  <span class="kwrd">&lt;/</span><span class="html">OBJECT</span><span class="kwrd">&gt;</span><br />

And the more complex example:

  <span class="kwrd">&lt;</span><span class="html">IFRAME</span> <span class="attr">src</span><span class="kwrd">="foo.html"</span> <span class="attr">width</span>=<span class="attr">400</span> <span class="attr">height</span>=<span class="attr">500</span> <span class="attr">scrolling</span>=<span class="attr">auto</span><br />     <span class="attr">frameborder</span>=<span class="attr">1</span><span class="kwrd">&gt;</span><br />  that unfortunately your user agent doesn't support. Alternatively you<br />  can get the related document <span class="kwrd">&lt;</span><span class="html">a</span> <span class="attr">href</span><span class="kwrd">="foo.html"</span><span class="kwrd">&gt;</span>here<span class="kwrd">&lt;/</span><span class="html">a</span><span class="kwrd">&gt;</span>.<br />  <span class="kwrd">&lt;/</span><span class="html">IFRAME</span><span class="kwrd">&gt;</span><br />

Becomes:

<span class="kwrd">&lt;</span><span class="html">OBJECT</span> <span class="attr">src</span><span class="kwrd">="foo.html"</span> <span class="attr">width</span>=<span class="attr">400</span> <span class="attr">height</span>=<span class="attr">500</span><span class="kwrd">&gt;</span><br />  <span class="kwrd">&lt;</span><span class="html">PARAME</span> <span class="attr">name</span>=<span class="attr">scrolling</span> <span class="attr">value</span>=<span class="attr">auto</span><span class="kwrd">&gt;</span><br />  <span class="kwrd">&lt;</span><span class="html">PARAME</span> <span class="attr">name</span>=<span class="attr">frameborder</span> <span class="attr">value</span>=<span class="attr">1</span><span class="kwrd">&gt;</span><br />  that unfortunately your user agent doesn't support. Alternatively you<br />  can get the related document <span class="kwrd">&lt;</span><span class="html">a</span> <span class="attr">href</span><span class="kwrd">="foo.html"</span><span class="kwrd">&gt;</span>here<span class="kwrd">&lt;/</span><span class="html">a</span><span class="kwrd">&gt;</span>.<br />  <span class="kwrd">&lt;/</span><span class="html">OBJECT</span><span class="kwrd">&gt;</span><br />

You can visit the W3 Frames page, and find IFRAME vs OBJECT about 2/3rds of the way down the document.  (It’s slightly slanted in favor of IFrame and doesn’t explain a lot of the security issues around using IFrame in IE.)

http://www.w3.org/TR/WD-frames-970331

Tweet about this on TwitterShare on Google+Share on FacebookShare on RedditEmail this to someoneShare on LinkedInShare on StumbleUpon

Leave a Reply

Your email address will not be published. Required fields are marked *