SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Member saileyn's Avatar
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question display a html file within a <div>?

    I've finally managed to get the hang of CSS (I think anyway!) and I was wondering if this is possible:

    I have a number of different div's on my page, including a navigation div and a content div. Am I able to include a link in the navigation div to a html file (that contains different content) and have that load into the content div when it's clicked? So, it would basically work similar to a frames page, where your links are in one frame and the content all displays in another but doesn't have to reload the whole index page over and over.

    And just so you know, I'm not that advanced in any form of scripting languages, aside from a little tweaking, trail and error in Javascript....

    Any help would be appreciated, thanks!
    saileyn

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2002
    Location
    Bristol, UK
    Posts
    2,240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you know whether your server allows you to use PHP or SSI?

    -Sam
    Sam Hastings

  3. #3
    SitePoint Member saileyn's Avatar
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your response!

    I do have access to PHP but I have no idea what SSI is and I'm pretty sure I can't get that anyway...

    What do you suggest?
    saileyn

  4. #4
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Well if you have PHP (which is faster than SSI), try something like this
    Code:
    <div class="classname">
        <?php include("/path/to/file.html"); ?>
    </div>

  5. #5
    SitePoint Enthusiast irishstu's Avatar
    Join Date
    Aug 2003
    Location
    Dublin Ireland
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  6. #6
    SitePoint Member saileyn's Avatar
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys, I'll give both methods a go when I get a chance and let you know how it turns out.
    saileyn

  7. #7
    SitePoint Member saileyn's Avatar
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, I've been messing around with the PHP solution and can get the include function to display the file in the content div but...

    How do I change what html file appears in the content div when I click a link? Here's a snippit of what I have so far:

    <div id="content">
    <?php include("home.html" ); ?>
    </div>

    <div id="navigation">
    <a class="nav" href="##">Home</a>
    <a class="nav" href="##">About</a>
    </div>

    What do I insert in place of the ## (they're there for appearances sake just because I don't know what to use) Obviously if I put home.html or about.html they will just open up as a normal separate page and won't be inside the content div like I want them to be.

    Hope that made sense! Thanks
    saileyn

  8. #8
    SitePoint Evangelist ucahg's Avatar
    Join Date
    Apr 2001
    Location
    Sarnia, Ontario, Canada
    Posts
    434
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    An IFRAME would be more suited for this type of endeavor.

    Skip the <div>, just use <iframe src="bar.html" width="x" height="y">Sorry, your browser doesn't support inline frames. <a href="bar.html">See the page that should be here.</a></iframe>.

    You can run a search on google and find out how to use iframes (because I'm going on memory here) but basically if the browser supports it (IE4+, NS6+, Mozilla, Opera, etc.) then it will display the document in a frame. If not, it displays what's between the <iframe> and </iframe> tags.
    Love it? Hate it? Helpful? Useless?
    Use the rate button to let me know what you think of my post!

  9. #9
    American't awestmoreland's Avatar
    Join Date
    Sep 2002
    Location
    Grand Rapids, MI
    Posts
    1,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by saileyn
    How do I change what html file appears in the content div when I click a link?
    <a class="nav" href="##">Home</a>
    What do I insert in place of the ##
    PHP code is only actioned on the server, therefore you would have to refresh the page after selecting a link for the new content to be displayed.

    How much information will you be displaying on each page? It's not a practical solution for a large site as there's a real overhead on initial loading, but if it's a relatively small site with limited graphics, I like to use hidden divs. Example.

    Assuming you have SSI supported, you can then use includes from external files to populate your page on loading. I note that you say that you don't think that you have SSI, but it's definitely worth checking with a simple SHTML page.
    From the English nation to a US location.


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
  •