Sitecore iframe validation

According to the XHTML 1.1 specifications, iframes are deprecated and should be replaced by object tags. Sitecore validation correctly fails on any pages with iframes. Unfortunately, there are some edge cases where object tags do not always work (IE8, I’m looking at you). In the majority of cases, I’ve used object tags to embed content successfully while conforming to validation; however, in the one case where I’ve seen IE8 fail I’ve had to resort to using this javascript hack. This allows the page to validate successfully and embeds the content properly in IE8.

This javascript function writes out the iframe to the document:

Here’s the method in the sublayout code-behind that renders the javascript. “CurrentItem” is assumed to be the item in the current Sitecore context and not shown (CurrentItem is set in the sublayout’s base class.)

It’s not pretty, but it gets the job done. I hope this helps!

This entry was posted in it and tagged , . Bookmark the permalink.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>