Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-18-2012, 07:25 PM   PM User | #1
willscarlet
New Coder

 
Join Date: Aug 2012
Posts: 65
Thanks: 5
Thanked 0 Times in 0 Posts
willscarlet is an unknown quantity at this point
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..
willscarlet is offline   Reply With Quote
Old 09-18-2012, 07:41 PM   PM User | #2
tracknut
Regular Coder

 
Join Date: Aug 2006
Posts: 907
Thanks: 4
Thanked 212 Times in 211 Posts
tracknut is an unknown quantity at this point
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
tracknut is offline   Reply With Quote
Old 09-18-2012, 10:00 PM   PM User | #3
bathroomgirl
New to the CF scene

 
Join Date: Sep 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
bathroomgirl is an unknown quantity at this point
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!
bathroomgirl is offline   Reply With Quote
Old 09-18-2012, 10:13 PM   PM User | #4
Sammy12
Registered User

 
Join Date: Jun 2011
Posts: 1,063
Thanks: 12
Thanked 241 Times in 240 Posts
Sammy12 is on a distinguished road
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..
Sammy12 is offline   Reply With Quote
Old 09-18-2012, 11:07 PM   PM User | #5
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,703
Thanks: 5
Thanked 875 Times in 850 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
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.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:02 AM.


Advertisement
Log in to turn off these ads.