PDA

View Full Version : Dump iframes and use object elements instead


456 Berea Street
14th Dec 2006, 08:54 pm
Do you sometimes need to use iframe elements to inject content into sites you build? I do. Not very often, luckily, but it does happen. Usability and accessibility issues aside, doing so also forces me to use a transitional DOCTYPE, something I'd rather avoid.
There is an option, but it is of little practical use since it doesn't work in Internet Explorer: the object element. Or so it was believed. The other day I came across Stuart Colville's post No more iframes? (http://muffinresearch.co.uk/archives/2006/11/27/no-more-iframes/). In the post, Stuart points to Aleksandar Vaci?'s article Insert HTML page into another HTML page (http://www.aplus.co.yu/web-dev/insert-html-page-into-another-html-page/), which explains a very clever way of using an object element to insert an external HTML document into a page.
Aleksandar solved the problem by finding a value for the object element's classid attribute that makes IE accept an external HTML document as the content of the object element. And it actually seems to work. Stuart discussed Aleksandar's technique with a couple of colleagues and cleaned it up slightly code-wise. View Using an object Element instead of an iframe (http://intranation.com/test-cases/object-vs-iframe/) for a demo and explanation.
I haven't tried this myself yet, but I'm sure I'll find an opportunity to do so sooner than I'd like to.
Visit site to read or post comments… (http://www.456bereastreet.com/archive/200612/dump_iframes_and_use_object_elements_instead/#comments)Add 456 Berea Street to your Technorati favorites. (http://technorati.com/faves?add=http://www.456bereastreet.com)
Posted in (X)HTML (http://www.456bereastreet.com/archive/categories/xhtml/), Browsers (http://www.456bereastreet.com/archive/categories/browsers/).
http://feeds.feedburner.com/~a/456bereastreet?i=ywrtrF</img> (http://feeds.feedburner.com/~a/456bereastreet?a=ywrtrF)


More... (http://www.456bereastreet.com/archive/200612/dump_iframes_and_use_object_elements_instead/)