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!


Page 3 of 3 FirstFirst 123
Results 21 to 29 of 29
  1. #21
    Join Date
    Mar 2005
    Location
    Leeds
    Posts
    3,423
    Tokens
    0

    Latest Awards:

    Default

    Nice one, very interesting ;]

    Quote Originally Posted by redtom View Post
    Great now watch all the habbo site change from iframes to this, thats why no one was giving it out, but it's your code you can do what you want with it, + rep anyway.
    mmm, if you search on google for 30 seconds you will find a number of libs/tutorials.

  2. #22

    Default

    Hey, sorry to bump a little, but would this be possible to load a page, showing how many users online (I have the .php with the code), then an ajax reload that reloads every 30 seconds?
    I'm not going to be using this account anymore, after today!

  3. #23
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    Yup very easy.

    youd want somthing along these lines
    Code:
    //Calls function every 30 seconds. (function takes time in miliseconds)
    setInterval(Getstats, 30000);
    //id of div to put stats in to
    var divname = "Mydiv";
    var statpage ="stats.php";
    
    function Getstats() {
             // Set up request varible
             try {xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");}  catch (e) {}
             //send Request
             xmlhttp.onreadystatechange = function(){
                     //Check page is completed and there were no problems.
                     if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
                            //Write data returned to div
                            document.getElementById(divname).innerHTML = xmlhttp.responseText;
                     }
             }
             xmlhttp.open("GET", statpage);
             xmlhttp.send(null);
    }
    What the above will do is write the contentes of "stats.php" to a div by the name of "Mydiv" every 30 seconds.
    Stats.php just needs to change its contence so the stats are correct every time it is loaded, that will then be shown in the div.

    You change the div being used or the page being loaded via the two varibles:
    var divname = "Mydiv";
    var statpage ="stats.php";

    Again, i havent tested it works so there could be a problem in it, hopefuly theres not, but if there is feel free to ask for help with it.

    Also it may be a good idea to add some headers in the php of the page stats are loaded from to stop the brower cacheing that page.

    hope that helps

    ps. if theres an error and it doesnt load, the script just wont right anything, as opposed to alerting theres a problem as with the page load scripts.
    Last edited by Mentor; 21-04-2007 at 11:31 PM.

  4. #24

    Default

    Ah man, you are awesome. I shall test now, thanks very much!
    I'm not going to be using this account anymore, after today!

  5. #25
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    ok, hope it all works

  6. #26

    Default

    I think my mysql databases are down - what a bad time for that to happen eh? I'll have to wait untill they're back up to see if it works.

    As it shows the User online: 1 but it doesnt update even when my friends on (but its not your code, its actually the stats script). So I will post here when its back up! =)

    thanks again!

    EDIT: its not my mysql databases, must be my code. hmm, ill fix it and post back thanks!
    Last edited by UnderGROUND; 21-04-2007 at 11:57 PM.
    I'm not going to be using this account anymore, after today!

  7. #27

    Default

    I cant edit, so here we goooo. I fixed my script.

    I have the div for where I want it to be show as <div name="online"></div> and the part in your code is: var divname = "online";

    yet it doesn't work, I think im doing something wrong It just displays 1 user online. and doesnt go up.
    I'm not going to be using this account anymore, after today!

  8. #28
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    Can you pm me a link to the page your useing it on? that way i can check to see whats going wrong with it

  9. #29

    Default

    Sure, I have done ^^
    I'm not going to be using this account anymore, after today!

Page 3 of 3 FirstFirst 123

Posting Permissions

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