Load parts of a page as needed?

Discussion in 'HTML' started by CRON, Jan 15, 2007.

  1. CRON

    CRON Guest

    Hi!,
    Anyone know a way to save on loading times by only loading part of the
    page after a link is clicked? iframes is an obvious solution but it
    would be messy. Is it possible to change the content of a div when a
    link is clicked?
    Cheers,
    Ciarán
     
    CRON, Jan 15, 2007
    #1
    1. Advertising

  2. CRON

    J.O. Aho Guest

    CRON wrote:
    > Hi!,
    > Anyone know a way to save on loading times by only loading part of the
    > page after a link is clicked? iframes is an obvious solution but it
    > would be messy. Is it possible to change the content of a div when a
    > link is clicked?


    Yes, you can do that with help of javascript (even jscript works, but then you
    lock out a good number of users)

    --- javascript ---
    function showdiv(id)
    {
    el = document.getElementById(id);
    if (el.style.display == 'none') {
    el.style.display = '';
    el = document.getElementById('_' + id);
    } else {
    el.style.display = 'none';
    el = document.getElementById('_' + id);
    }
    return false;
    }
    --- eof ---

    --- the div ---
    <div id="divID">Something here!</div>
    --- eof ---

    --- the link ---
    <a href="" title="The Link" onclick="javascript:showdiv('divID');return
    false;">The Link to show or hide div named divID</a>
    --- eof ---

    Should work on all javascript supporting browsers.

    --

    //Aho
     
    J.O. Aho, Jan 15, 2007
    #2
    1. Advertising

  3. CRON

    CRON Guest

    Cool thanks for the quick reply - I'll check it out.
     
    CRON, Jan 15, 2007
    #3
  4. CRON

    CRON Guest

    Aho,
    Thanks for the effort but this script isn't quite what I wanted. The
    display:none css property doesn't actually prevent the content from
    loading, it just hides it from the user. I need something that works
    like this that does not load the new content until the link is clicked.


    The reason for this is my page is very long and complicated and I am
    trying to stagger the loading time of the content. I cannot split the
    page into new pages.

    Anyone else have an idea?
    Thanks Ciarán
     
    CRON, Jan 15, 2007
    #4
  5. CRON

    J.O. Aho Guest

    CRON wrote:
    > Thanks for the effort but this script isn't quite what I wanted. The
    > display:none css property doesn't actually prevent the content from
    > loading, it just hides it from the user. I need something that works
    > like this that does not load the new content until the link is clicked.


    Okey, then you have to go with AJAX and some serverside scripting and use
    javascript to write out portion of the text. You will get a load of work to
    get roughly the same effect as frame/iframe.


    > The reason for this is my page is very long and complicated and I am
    > trying to stagger the loading time of the content. I cannot split the
    > page into new pages.


    Surely you can cut it up, I still haven't seen a book where you have only one
    page.

    --

    //Aho
     
    J.O. Aho, Jan 15, 2007
    #5
  6. CRON wrote:
    > Hi!,
    > Anyone know a way to save on loading times by only loading part of the
    > page after a link is clicked? iframes is an obvious solution but it
    > would be messy. Is it possible to change the content of a div when a
    > link is clicked?


    No the obvious solution is break the page up! Too much on a page is bad
    design. No one likes to enter a page and wait ten minutes as the "scroll
    to China" is created.

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Jan 15, 2007
    #6
  7. CRON

    Toby Inkster Guest

    CRON wrote:

    > Anyone know a way to save on loading times by only loading part of the
    > page after a link is clicked? iframes is an obvious solution but it
    > would be messy. Is it possible to change the content of a div when a
    > link is clicked?


    AJAX is the obvious solution, but even better would be to split the file
    into several pages and offer links like

    <- previous page [page 2 of 14] next page ->

    at the top and bottom of each page. People understand prev/next links like
    this -- most search engines include them in results listings.

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
     
    Toby Inkster, Jan 15, 2007
    #7
  8. CRON

    CRON Guest

    Thanks guys but it's not really as simple as that, The page doesn't
    just flow down, I have a lot of dynamic content nested in popup forms
    and things like that. For example, I have 50 smileys that load on every
    page just in case a user decides to post a message. I'd like a way to
    prevent these from loading before they are needed. That's just one
    thing. My site has a lot of features that favour useability over
    loading speed and I'm just trying to take some of the load times down a
    little if I can.
     
    CRON, Jan 15, 2007
    #8
  9. CRON

    Andy Dingley Guest

    CRON wrote:

    > Anyone know a way to save on loading times by only loading part of the
    > page after a link is clicked?


    New page or navigation between related pages ?

    If it's a whole new page, then try to re-design for a smaller, simpler
    page. With today's coding practices and bandwidth, it's unusual to
    require a page to be slow to load. If it's small enough to be
    comprehensible in one chunk, then that's also technically light enough
    to arrive speedily.

    If it's navigation between related pages, or anything that suggests
    itself as an iframe, then look into AJAX. Beware though that for simple
    situations, the <iframe> solution is often simpler, better and doesn't
    have problesm that a simple AJAX solution won't itself suffer from
    (bookmarking in particular).
     
    Andy Dingley, Jan 15, 2007
    #9
  10. CRON wrote:
    > Thanks guys but it's not really as simple as that, The page doesn't
    > just flow down, I have a lot of dynamic content nested in popup forms
    > and things like that. For example, I have 50 smileys that load on every
    > page just in case a user decides to post a message. I'd like a way to
    > prevent these from loading before they are needed. That's just one
    > thing. My site has a lot of features that favour useability over
    > loading speed and I'm just trying to take some of the load times down a
    > little if I can.
    >

    If it takes lots of time then it is *not* usable! If page *needs* to be
    so large, maybe your should think your overall design.

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Jan 15, 2007
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt Swift
    Replies:
    1
    Views:
    335
    =?Utf-8?B?TG95IEIgSw==?=
    May 27, 2004
  2. Replies:
    3
    Views:
    609
    Keith Thompson
    Mar 31, 2007
  3. Replies:
    1
    Views:
    964
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Apr 12, 2007
  4. kizk
    Replies:
    0
    Views:
    624
Loading...

Share This Page