...

View Full Version : <iframe> doesnt validate in xhtml strict



samtaleterapi
01-19-2012, 07:12 PM
hi

i have embedded a youtube video on my site with the suggested code
<iframe width="477" height="272" src="http://www.youtube.com/embed/UDQshihvWG8?rel=0" frameborder="0" allowfullscreen></iframe>
it doesnt validate in xhtml strict

what is the wisdom on this problem?
different doctype or different code?
does the above mentioned code work across browsers?

thanks
rasmus

ps im happy to name my website but i seem to remember that i need to post more first

SeattleMicah
01-19-2012, 07:46 PM
did you try embedding with their html version? Just wondering...

felgall
01-19-2012, 08:21 PM
HTML 4 has the <object> tag as a replacement for <iframe>

If you want to use <iframe> then you need to use an earlier version of HTML that still supported it. The HTML 4 transitional doctyle does support using <iframe> because it was a popular proprietary tag back in the days when the latest standard was HTML 3.2 and those who released HTML 4 in 1997 decided that they would accept that tag for those transitioning their HTML 3.2 code into HTML 4 even though it wasn't really part of HTML 3.2. Of course most people still haven't transitioned from using <iframe> to using the standard <object> tag that replaced it but then there are still people using old versions of Internet Explorer that have a few minor issues with using an object tag to attach HTML.

For some unexplainable reason there is a proposal to actually introduce iframe as a standard tag in HTML 5 even though all the browsers that will support HTML 5 will also support the correct use of the object tag intended for this purpose.

samtaleterapi
01-24-2012, 06:59 PM
so which is better across different browsers? new and old?
iframe html 4 transitional or object xhtml 1.0 strict?
thanks
rasmus

felgall
01-24-2012, 08:26 PM
The object tag works correctly for inserting an external page in the latest versions of all browsers and in all of the earlier versions people are likely to be using with the exception of Internet Explorer. With old versions of IE you don't get full control of whether a border will display around the page or not. There's also a proprietary attribute needed on the object tag for IE6.

Provided that you don't need to support IE6 you can use:


<object type="text/html" data="xiframe.htm"
style="height:200px; width:200px;">
<p>Alternate text.</p>
</object>

Which will display the content of xiframe.htm at that spot in the page in all common browsers except IE6. Those browsers that don't support the object tag plus IE6 will see the alternate text instead. Those using IE7 or 8 may see a border around the content that can't be turned off

See http://www.felgall.com/noiframe.htm for a couple of variants that will also work in IE6 (but which still don't allow control of the border in IE7 or IE8). You can control the border in IE6 but it has to be done from within the page being included and not from the page that it is included in.

Using a transitional doctype and an iframe works around these difficulties for the moment. Once IE8 dies then the standard way using the object tag will be just as simple to use as the using a non-standard iframe tag. (Note that the browsers that don't support using the object tag fully also don't support HTML 5 so the iframe tag being added in HTML 5 means that it will become part of the standard long after it has ceased to serve any useful purpose).

samtaleterapi
01-25-2012, 07:05 AM
Thank you very much
Having now changed the doctype to transitional, the only thing that doesnt validate is the "allowfullscreen" tag
Can it be safely removed without loss of functionality?
Or is there a workaround?
Rasmus

riptide
01-25-2012, 07:20 AM
I would assume that's it's not necessary but the last time I use an Iframe it was non-resizable.

Arbitrator
01-25-2012, 07:52 AM
For some unexplainable reason there is a proposal to actually introduce iframe as a standard tag in HTML 5 even though all the browsers that will support HTML 5 will also support the correct use of the object tag intended for this purpose.HTML5's iframe element will have features that object does not. For example, two such features are seamless page integration of the framed content into the current document with the seamless attribute and security restrictions via the sandbox attribute.

Plus, iframe elements can be addressed (to call a new document) without the use of script, unlike object elements.


the only thing that doesnt validate is the "allowfullscreen" tag
Can it be safely removed without loss of functionality?This is an "attribute" (not a tag). There's no workaround to get it to validate.

The attribute is apparently part of Mozilla's recent FullScreenAPI project (https://wiki.mozilla.org/Gecko:FullScreenAPI#iframe_allowfullscreen_attribute), which they're designing as a new standard and allows framed content to use full-screen functionality. (Maybe it'll appear in HTML5 in the future, but it's not there now.)

You should be able to safely remove it, though I'd guess that it may prevent use of the full screen in Firefox. (You'll have to test it and see.)

samtaleterapi
01-25-2012, 08:01 AM
removing it doesnt seem to hamper the fullscreen capability in firefox
thanks
im content for now
rasmus

felgall
01-25-2012, 09:57 AM
HTML5's iframe element will have features that object does not. For example, two such features are seamless page integration of the framed content into the current document with the seamless attribute and security restrictions via the sandbox attribute.

Plus, iframe elements can be addressed (to call a new document) without the use of script, unlike object elements.

But why add an entire new tag just to add those extra attributes/functionality rather than just adding them to the one already in the standards? Just another one of those things that shows that those developing HTML 5 do not understand what standards are (after all they have decided not to follow the document markup standards in defining their new language when one of the most significant changes in HTML 2 was that it was redefined to follow the SGML standards for how to define a markup language).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum