Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New Coder
    Join Date
    Oct 2007
    Posts
    20
    Thanks
    2
    Thanked 0 Times in 0 Posts

    <iframe> doesnt validate in xhtml strict

    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

  • #2
    Regular Coder
    Join Date
    Dec 2011
    Posts
    201
    Thanks
    12
    Thanked 26 Times in 26 Posts
    did you try embedding with their html version? Just wondering...

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,472
    Thanks
    0
    Thanked 634 Times in 624 Posts
    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.
    Last edited by felgall; 01-19-2012 at 08:24 PM.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • Users who have thanked felgall for this post:

    SeattleMicah (01-19-2012)

  • #4
    New Coder
    Join Date
    Oct 2007
    Posts
    20
    Thanks
    2
    Thanked 0 Times in 0 Posts
    so which is better across different browsers? new and old?
    iframe html 4 transitional or object xhtml 1.0 strict?
    thanks
    rasmus
    Last edited by samtaleterapi; 01-24-2012 at 07:38 PM.

  • #5
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,472
    Thanks
    0
    Thanked 634 Times in 624 Posts
    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:

    Code:
    <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).
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #6
    New Coder
    Join Date
    Oct 2007
    Posts
    20
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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
    Last edited by samtaleterapi; 01-25-2012 at 07:41 AM.

  • #7
    Regular Coder riptide's Avatar
    Join Date
    Jan 2007
    Posts
    143
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I would assume that's it's not necessary but the last time I use an Iframe it was non-resizable.

  • #8
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,276
    Thanks
    28
    Thanked 272 Times in 266 Posts
    Quote Originally Posted by felgall View Post
    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.

    Quote Originally Posted by samtaleterapi View Post
    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, 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.)
    Last edited by Arbitrator; 01-25-2012 at 08:47 AM. Reason: I fixed a typo; "current" should have been "current document"
    For every complex problem, there is an answer that is clear, simple, and wrong.

  • #9
    New Coder
    Join Date
    Oct 2007
    Posts
    20
    Thanks
    2
    Thanked 0 Times in 0 Posts
    removing it doesnt seem to hamper the fullscreen capability in firefox
    thanks
    im content for now
    rasmus

  • #10
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,472
    Thanks
    0
    Thanked 634 Times in 624 Posts
    Quote Originally Posted by Arbitrator View Post
    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).
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •