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 5 of 5
  1. #1
    New Coder
    Join Date
    Aug 2012
    Posts
    65
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Iframe Alternative

    This may be a dumb question but I have to ask all the same. I am making a website for a friend and I was wanting to have a left and right nav menu and between them is the large content area. The problem im having though, is how to make the content change in the box without actually changing the page, like a one page website but without the content all showing at once. I can do something like that with an Iframe but I am being told that I need to do it a different way, as Iframes are bad practice while im learning css/html.

    Essentially I want to make a one page website but without the scrolling

    any help or advice would be greatly appreciated. thank you guys for your time.
    Last edited by willscarlet; 09-18-2012 at 07:41 PM.

  • #2
    Senior Coder
    Join Date
    Aug 2006
    Posts
    1,224
    Thanks
    10
    Thanked 269 Times in 268 Posts
    You should just do this as multiple pages with the same left and right navigation on each page. Let the browser cache and/or redraw the same menus in the same place, and you'll hardly notice it as long as your menus don't move.

    Doing this with frames and/or iframes is certainly not current practice.

    Dave

  • #3
    New to the CF scene
    Join Date
    Sep 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can make an iframe-like DIV by adding "overflow: auto;" to your content DIV css. This way the page will not scroll.

    Make sure to specify a height for your DIV as well!

  • #4
    Registered User
    Join Date
    Jun 2011
    Posts
    1,063
    Thanks
    12
    Thanked 241 Times in 240 Posts
    Quote Originally Posted by willscarlet View Post
    This may be a dumb question but I have to ask all the same.
    Not a dumb question, pretty popular question in the PHP section.

    There is no way to accomplish what you are looking for through HTML/CSS, other than using the :target psuedo class, which doesn't have full browser support (only IE9+). Target Article, essentially you are passing a hash (#) value (www.website.com/index.php#blog) in the URL.

    ---------------------------

    Quote Originally Posted by willscarlet View Post
    The problem im having though, is how to make the content change in the box without actually changing the page, like a one page website but without the content all showing at once.
    You are talking about passing variables in the URL with PHP:

    Take a URL like this for instance: www.website.com/index.php?page=blog

    PHP Code:
    <div id="left-nav">Left Nav</div>

    <div id="main-content">
    <?php
    if($_GET['page'] == 'blog') {
    ?>
        <p>This is my blog. Since it is set after the "?", this part will show.</p>
    <?php>
    } elseif(
    $_GET['page'] == 'contact') {
    ?>
        <p>This is my contact page.</p>
    <?php
    }
    ?>
    </div>

    <div id="right-nav">Right</div>
    This way only a part of your website will change (and yes, this is preferable over iframes). Passing variables in the URL Article

    ---------------------------

    Quote Originally Posted by willscarlet View Post
    I can do something like that with an Iframe but I am being told that I need to do it a different way, as Iframes are bad practice while im learning css/html.
    iframes are not bad practice. They were meant to be used more for inserting external websites (something that is not related to your page), for instance a twitter "tweet" button. Everything with that button has different style, different scripts, and so on.

    @VIP it's 2012! Using an <object> for a twitter button?!?
    Last edited by Sammy12; 09-19-2012 at 12:35 AM.

  • #5
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,624
    Thanks
    6
    Thanked 1,001 Times in 974 Posts
    Quote Originally Posted by Sammy12 View Post
    iframes are not bad practice. They were meant to be used more for inserting external websites (something that is not related to your page), for instance a twitter "tweet" button. Everything with that button has different style, different scripts, and so on.
    Even though I’ve only been doing this since 2005 I would consider myself of the old school, and I’ve learned that frames, no matter which ones, are bad practice because they bear accessibility issues and because they require a lot of non-standard attributes to make them work/look alike in different browsers.

    And for that matter I’m still hesitant to recommend (i)frames, even though they regretfully have been re-added in HTML 5. The proper replacement/alternative to iframes is – in my old-school opinion – still the object element.


  •  

    Posting Permissions

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