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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need help using iframe to only reload part of the page

    Hey guys,

    The website that I'm working on is http://teaminmetsu.com
    I'd like to make it so that the content_box div (the main box under the content slider) is the only part of the page that reloads when the user clicks on a link. Whether that be a link from the roster or the forums button in the navbar. Any help will be greatly appreciated.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,210
    Thanks
    75
    Thanked 4,343 Times in 4,309 Posts
    So make it an <iframe>, as you said.

    Links inside the <iframe> of the form <a href="xxx">zzz</a> will automatically replace the current iframe contents.

    For links outside the <iframe> (if any) just use:
    Code:
    <a target="theRoster" href="xxx">change iframe contents</a>
    ...
    <iframe name="theRoster"></iframe>
    The iframe just needs a name and then the <a> element just needs to target that name.

    You can also use <form>s with targets:
    Code:
    <form target="theRoster" action="showFullRoster.php" method="post">...
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm trying to dynamically load only the content inside of a single div. Within this div is other div's, widgets, etc... I don't see how I can use an iframe for this. Could you provide me some examples that are specific to my case?

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,210
    Thanks
    75
    Thanked 4,343 Times in 4,309 Posts
    To load the content into a <div>, you'll need to use AJAX.

    I believe, though, that jQuery has this capability built in. (Loading a URL into a <div>, that is.) If not, google for a jQuery function that will do so.

    It's not clear to me why you couldn't use an <iframe> inside your <div>, but if you say you can't, I guess you can't.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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