Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 9 of 9
  1. #1
    Join Date
    Nov 2005
    Posts
    4,486
    Tokens
    921

    Latest Awards:

    Default AJAX - When page loads, load it into a DIV.

    - SOLVED -

    I've got my AJAX working, so if you click a link, It will load the page into the selected DIV.

    But how would I load somthing into the div, when the rest of the site loads, if you know what I mean.

    ***

    So say when you visit mysite.com - The layout loads.
    But atm I have the div with just 'AJAX CODE HERE', as text, in it.
    I want some AJAX code that'll make home.html load as soon as someone visits mysite.com.

    ***

    I'm awkward at explaining this but here's some help;
    When a link is clicked; javascript:ajaxpage('home.html', 'content');
    Div HTML; <div id="content" class="style3">AJAX CODE HERE</div>

    The AJAX CODE HERE is what shows when the page first loads.

    - TomSpit

    Last edited by Jahova; 27-05-2008 at 04:11 PM.
    "RETIRED" FROM HABBO(X)

    :¬:

    TOMSPIT / COWLY05


  2. #2
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    HTML Code:
    <script>
    window.onload = ajaxpage('home.html', 'content');
    </script>
    That should work, or you can simply modify your <body> tag to:

    HTML Code:
    <body onload="ajaxpage('home.html', 'content');">
    Last edited by Invent; 27-05-2008 at 04:04 PM.

  3. #3
    Join Date
    Nov 2005
    Posts
    4,486
    Tokens
    921

    Latest Awards:

    Default

    Thanks alot,
    I used the bottom one and it works great.

    I'm learning AJAX and trying to improve my overall coding, and I was just stuck on this small bit, so thank you.

    + Reppingly
    - Tom
    "RETIRED" FROM HABBO(X)

    :¬:

    TOMSPIT / COWLY05


  4. #4
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    Good to hear !

  5. #5
    Join Date
    Nov 2005
    Posts
    4,486
    Tokens
    921

    Latest Awards:

    Default

    New problem:
    On the same page, I have another div, that I want to load another page on.
    How would I do that?

    I have tried adding;
    <body onload="ajaxpage('content/home.html', 'content');" onload="ajaxpage('content/home.html', 'content');">

    And also;
    <script>
    window.onload = ajaxpage('home.html', 'content');
    </script>


    But it doesn't seem to be working.

    - Tom
    "RETIRED" FROM HABBO(X)

    :¬:

    TOMSPIT / COWLY05


  6. #6
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    All you need to do is add the ajaxpage() function again to to the body onload, like this:

    HTML Code:
    <body onload="ajaxpage('home.html', 'content'); ajaxpage('newpage.html', 'newdiv');">

  7. #7
    Join Date
    Nov 2005
    Posts
    4,486
    Tokens
    921

    Latest Awards:

    Default

    Thanks for all this help.
    And now another BIG problem.

    I have cutenews on my site, and when I click to go into full story.
    I don't know how to make it load into the div.

    As it's cutenews and it's used to loading in frames or new pages, now it will load into a new page but I don't know how to make it load into the div.

    - Tom
    "RETIRED" FROM HABBO(X)

    :¬:

    TOMSPIT / COWLY05


  8. #8
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    To fix that you need to change your shows.inc.php file so that all the links run the javascript function instead of loading a page.

    If you can't do this yourself, I'll do it for you when I get a chance

  9. #9
    Join Date
    Nov 2005
    Posts
    4,486
    Tokens
    921

    Latest Awards:

    Default

    If you could do it please =D
    Last edited by Jahova; 27-05-2008 at 07:22 PM.
    "RETIRED" FROM HABBO(X)

    :¬:

    TOMSPIT / COWLY05


Posting Permissions

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