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 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 29
  1. #11
    Join Date
    Dec 2006
    Location
    None of your business!
    Posts
    2,492
    Tokens
    50

    Latest Awards:

    Default

    Quote Originally Posted by ScottDiamond View Post
    Why did you just quote the whole post? And Carl, thanks for explaining every line to me in MSN lol.
    Ooops, sorry I'm used to quoting things.

  2. #12
    ScottDiamond Guest

    Default

    =D =D =D =D

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

    Latest Awards:

    Default

    Quote Originally Posted by Invent View Post
    Why not just use a simple preg_match function checking for say MSIE against $_SERVER['HTTP_USER_AGENT'] for internet explorer?
    Thats how mine works :p

  4. #14
    Join Date
    Dec 2006
    Location
    Doncaster, UK
    Posts
    4,244
    Tokens
    0

    Latest Awards:

    Default

    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.
    That's a bit selfish don't you think?

    Code is out there to be used; not allowing someone to use it in such a way is denying people of the privledge to use it?

    It was on DD for the record.
    A collection of forum users' views on obesity
    Quote Originally Posted by mynameisjake View Post
    sounds good
    Quote Originally Posted by Stephen View Post
    Just google it.
    Quote Originally Posted by jesus View Post
    jesus christ
    Quote Originally Posted by Alexicles. View Post
    It will probably soon go away.

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

    Latest Awards:

    Default

    Quote Originally Posted by Xeoro View Post
    That's a bit selfish don't you think?

    Code is out there to be used; not allowing someone to use it in such a way is denying people of the privledge to use it?

    It was on DD for the record.
    Mine has less crap in it than DD's.
    DD's stuff always seems to be incredibly long winded and inefficient for no real reason "/
    On the topic of including to much crap i combined it in to a single function, i think it will still work, i haven't tested again, main differences is i put the second function in the first.

    Code:
    function LoadPage(page,usediv) {
             // Set up request varible
             try {xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");}  catch (e) { alert("Error: Could not load page.");}
             //Show page is loading
             document.getElementById(usediv).innerHTML = 'Loading Page...';
             //scroll to top
             scroll(0,0);
             //send data
             xmlhttp.onreadystatechange = function(){
                     //Check page is completed and there were no problems.
                     if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
                            //Write data returned to page
                            document.getElementById(usediv).innerHTML = xmlhttp.responseText;
                     }
             }
             xmlhttp.open("GET", page);
             xmlhttp.send(null);
             //Stop any link loading normaly
             return false;
    }
    Im working on the assumption formating like this means i dont need to define a globally scoped variable (which cases problems if your actually useing the asynchronous part of ajax), and that i used the inline function syntax right.
    Last edited by Mentor; 17-04-2007 at 06:39 PM.

  6. #16
    Join Date
    Feb 2006
    Location
    Ontario Canada
    Posts
    4,587
    Tokens
    0

    Latest Awards:

    Default

    anway to make the content load so many pixels to the rite of the beginning of the content box? and thanks mentor
    do i still have news privladges on your site?

    .:.:#14:.:. .:.: Impossible Is Nothing :.:. .:.: 845 Rep:.:.
    .:.: Stand up for what is right, even if you stand alone:.:.


  7. #17
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    Quote Originally Posted by Colin-Roberts View Post
    anway to make the content load so many pixels to the rite of the beginning of the content box? and thanks mentor
    do i still have news privladges on your site?
    not sure why you would want to, but if your asking what i think you are, easyst way would just be add a margin or padding in CSS to the div your loading the content in to ?

    Also just for the hell of it, even smaller version
    Code:
    function LoadPage(p,d) {
             try {xh = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");}  catch (e) { alert("Error: Could not load page.");}
             pd = document.getElementById(d); pd.innerHTML = 'Loading Page...'; scroll(0,0);
             xh.onreadystatechange = function(){if ((xh.readyState == 4) && (xh.status == 200)) {pd.innerHTML = xh.responseText;}}
             xh.open("GET", p); xh.send(null);  return false;
    }

  8. #18
    Join Date
    Jan 2006
    Location
    Cambridge
    Posts
    1,911
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by 01101101entor View Post
    Ok, theres been a few people asking for this lately so i thought id provide a script ive written. What an ajax load normaly is, is a method where an xmlhttp request is made via javascript and the content of a page is dynamically loaded in to a div of your choice.
    Currently im going to provide a very basic script, which just takes a page and displays the contents in a div, via ajax.
    I may later add an advanced version which will support additional function, to work with a php navigation meaning search engines can still crawl the content, the back button and favorites still works.

    Basic script

    Features:
    > Shows page is loading
    > dynamically loads page to a div.

    Code:
    <script>
    //Set up variables
    var xmlhttp ;
    var thediv;
    function LoadPage(page,usediv) {
             // Set up request varible
             try {xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");}  catch (e) { alert("Error: Could not load page.");}
             //Show page is loading
             document.getElementById(usediv).innerHTML = 'Loading Page...';
             //scroll to top
             scroll(0,0);
             //Store div in use
             thediv = usediv;
             //send data
             xmlhttp.onreadystatechange = ShowPage;
             xmlhttp.open("GET", page);
             xmlhttp.send(null);
             //Stop any link loading normaly
             return false;
    }
    function ShowPage(){
             //Check page is completed and there were no problems.
             if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
                    //Write data returned to page
                    document.getElementById(thediv).innerHTML = xmlhttp.responseText;
             }
    }
    </script>
    This function can now be called via creating a link like this.

    <a href="mypage.htm" onclick="return LoadPage('mypage.htm','mydiv');">

    The above would place the contents of "mypage.htm" in to a div with the id "mydiv" such as could be written '<div id="mydiv"></div>'

    The parts of the link in bold being what need editing.

    I wrote the script on the go so its completely untested but should hopefully work. If it doesnt post back with the problem and ill sort it out for you.

    Edit: phew noticed just in time, id forgotten to store the div id in the function independents variable, which would have stopped it from working, should be fixed now.

    FIT ily - +rep
    EDTALKING


  9. #19
    Join Date
    Jul 2004
    Location
    Sunshine Coast, Queensland, AU
    Posts
    1,830
    Tokens
    467

    Latest Awards:

    Default

    Good work bag

  10. #20
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    As an exspantion, an updated version which now allows people to bookmark pages loaded via ajax. And Allows the backbutton to function correctly in firefox (not IE as that doesnt change the URI when a new hash is set)

    Long version

    Code:
    var CurrentPage;
    function LoadPage(page,usediv) {
             // Set up request varible
             try {xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");}  catch (e) { alert("Error: Could not load page.");}
             //Show page is loading
             document.getElementById(usediv).innerHTML = 'Loading Page...';
             //scroll to top
             scroll(0,0);
             //Change loaction hash.
             document.location.hash = page;
             //Store current page.
             CurrentPage = document.location.hash;
             //send data
             xmlhttp.onreadystatechange = function(){
                     //Check page is completed and there were no problems.
                     if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
                            //Write data returned to page
                            document.getElementById(usediv).innerHTML = xmlhttp.responseText;
                     }
             }
             xmlhttp.open("GET", page);
             xmlhttp.send(null);
             //Stop any link loading normaly
             return false;
    }
    //Poll hash to see if back button has been pressed
    setInterval(CheckBack, 500);
    function CheckBack(){
            // if the hash has changed from what was set in the script reload page.
            if(CurrentPage !== document.location.hash){
                    LoadPage(document.location.hash);
            }
    }
    Short version
    Code:
    var cp;
    function LoadPage(p,d){
             try {xh=window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");} catch (e){alert("Error: Could not load page.");}
             pd=document.getElementById(d);h=document.location.hash;pd.innerHTML='Loading Page...';scroll(0,0);h=p;cp=h;
             xh.onreadystatechange=function(){if((xh.readyState==4)&&(xh.status==200)){pd.innerHTML=xh.responseText;}}
             xh.open("GET",p);xh.send(null);return false; }
    function CheckBack(){if(cp!==document.location.hash){LoadPage(document.location.hash);}} setInterval(CheckBack,500);
    Again both are completely untested but should work just fine

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

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