Results 1 to 7 of 7

Thread: iframe scrolling problem

  1. #1
    Join Date
    Jan 2006
    Location
    Derbyshire, UK
    Posts
    74
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default iframe scrolling problem

    I'm playing around with html5 and it doesn't support scrolling="no" attribute on the iframe tag.

    Here's my html code
    Code:
    <iframe name="slider-frame" src="slider.htm"></iframe>
    What css code would I need to prevent both Hori & Vert scroll bars just for that specific iframe?

    Thanks

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    To satisfy some browsers, you may actually have to go with scrolling="no".

    However, the HTML 5 standards method would be to give it css style of:

    Code:
    overflow: hidden;
    I think you know how to do that for just that element. If not:

    Code:
    <iframe style="overflow: hidden;" name="slider-frame" src="slider.htm"></iframe>
    Or (preferred) give the iframe a unique id attribute and style it by its id with that style in the stylesheet.

    Even using that and scrolling="no" may fall short in some browsers. In which case you will want to make the HTML and the BODY elements on the slider.htm page also overflow hidden.

    It should be noted that it isn't so much HTML 5 not supporting scrolling="no", as its being non-standard for that DOCTYPE. Support is determined by the browser. It doesn't (in this case) hurt to include scrolling="no" for those browsers that might need it.
    Last edited by jscheuer1; 04-09-2011 at 08:49 AM. Reason: English Usage
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jan 2006
    Location
    Derbyshire, UK
    Posts
    74
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default

    Thanks for that, but how do you refer to that specific iframe, name="slider-iframe", in the stylesheet and one issue worth mentioning... by including scrolling="no" the code doesn't validate.

  4. #4
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    use id="slider-iframe" in the iframe element and then this in the stylesheet;

    Code:
    #slider-iframe { overflow: hidden; }
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by Beverleyh View Post
    use id="slider-iframe" in the iframe element and then this in the stylesheet;

    Code:
    #slider-iframe { overflow: hidden; }
    That's right, and the iframe would then look like so:

    Code:
    <iframe id="slider-iframe" name="slider-frame" src="slider.htm"></iframe>
    But you could use any valid cross browser selector that would single out that iframe. Like - say it's the only iframe on the page, then you could just use the iframe selector. Or if it's the only iframe inside an element with a unique id, you could use that element's id followed by iframe.

    Quote Originally Posted by Burgin View Post
    . . . by including scrolling="no" the code doesn't validate.
    That's also right. You're faced with some choices. You could use another DOCTYPE, one that allows that attribute. Or you could live with it not validating. As I said, in this case that won't hurt anything. Or you could choose not to support those browsers that require scrolling="no".

    For that last choice they are all IE, and all browsers built on the IE browser engine, perhaps one or more others. Using IE 9 here, it appears to be all versions of IE. However, using:

    Code:
    <style type="text/css">
    html, body {
    	overflow: hidden;
    }
    </style>
    on the page inside the iframe, in this case on slider.htm, appears to solve the problem. In fact, with that you probably don't need any style for this on the top page for any browser.

    So that's another and perhaps the best choice. But it does require that you have control over the style for that slider.htm page.

    There may be other choices. I can't think of any more at the moment.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #6
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,881
    Thanks
    49
    Thanked 266 Times in 258 Posts
    Blog Entries
    56

    Default

    Quote Originally Posted by jscheuer1 View Post
    [...] using:
    Code:
    <style type="text/css">
    html, body {
    	overflow: hidden;
    }
    </style>
    on the page inside the iframe, in this case on slider.htm, appears to solve the problem. [..]that's another and perhaps the best choice.
    That's the best choice indeed, because the css refers directly to the iframed page. I've encountered several problems concerning the styling of iframed pages that were solved when the css was given in the iframed pages themselves. But, as John said, you have to have control over them.
    ===
    Arie Molendijk.

  7. #7
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    That's certainly one to remember (for the iframed pages that you have control over) - definitely one to pencil in the experience notebook. Thanks for that chaps.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

Bookmarks

Posting Permissions

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