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

Thread: Refreshing DIV

  1. #1
    Join Date
    Mar 2006
    Posts
    121
    Tokens
    0

    Default Refreshing DIV

    Hey all, I've tried look for AJAX page refresh's, AJAX page fetchers, but strangely enough, nothing meets my requirements.. It's not to say I haven't found anything what so ever. I have actually found some things but don't do what I want though.

    I'm looking for a simple refresh that obviously doesn't refresh the whole page, but just refresh's a single DIV.

    Does anyone know how I would go about it and where I could perhaps find one?

    Thanks..

  2. #2
    Join Date
    Feb 2007
    Location
    Essex, England
    Posts
    1,392
    Tokens
    0

    Latest Awards:

    Default

    Use an iframe?

    Or pay some javascript wizz to do something in ajax for you.


  3. #3
    Join Date
    Mar 2006
    Posts
    121
    Tokens
    0

    Default

    I considered an iframe, but I didn't want the browser ticking all the time.

  4. #4
    Join Date
    Oct 2006
    Location
    Peterborough, UK
    Posts
    3,855
    Tokens
    216

    Latest Awards:

    Default

    Code:
    function start_div_update( )
    {
        setInterval("change_page('div name', 'file name', 'any variables')", 10000);
        // Change every 10 seconds (time you want x 1000) ---------------------^
    }
    function GetXmlHttpObject( )
    {
        var objXMLHttp = null
        if ( window.XMLHttpRequest )
        {
            objXMLHttp = new XMLHttpRequest( );
        }
        else if ( window.ActiveXObject )
        {
            // Haha oh wow, I got this from Wikipedia of all places.
            objXMLHttp = function(){
            try { return new ActiveXObject( "MSXML3.XMLHTTP" ); } catch( e ) { }
            try { return new ActiveXObject( "MSXML2.XMLHTTP.3.0" ); } catch( e ) { }
            try { return new ActiveXObject( "Msxml2.XMLHTTP" ); } catch( e ) { }
            try { return new ActiveXObject( "Microsoft.XMLHTTP" ); } catch( e ) { }
            throw new Error( "Could not find an XMLHttpRequest alternative. Please upgrade your browser or allow ActiveX Objects if you are using Internet Explorer." );
    };
        }
        return objXMLHttp;
    }
    function change_page( element, TheUrl, TheVars )
    {
        xmlHttp = GetXmlHttpObject( )
        if ( xmlHttp == null )
        {
            alert( "Your browser is either outdated or you have xmlHttp disabled, please upgrade your browser or enable xmlHttp requests." );
            return;
        }
        var url = TheUrl + "?" + TheVars + "&" + Math.random();
        //alert(url)
        xmlHttp.open( "GET", url ,true );
        xmlHttp.onreadystatechange = function ( )
        {
            if (xmlHttp.readyState == 4)
            {
                if (xmlHttp.status == 200)
                {
                    document.getElementById( element ).innerHTML = xmlHttp.responseText;
                }
            }
        };
        xmlHttp.send( null );
    }


    visit my internet web site on the internet
    http://dong.engineer/
    it is just videos by bill wurtz videos you have been warned

  5. #5
    Join Date
    Mar 2006
    Posts
    121
    Tokens
    0

    Default

    Oh thanks, I'll try it out.

  6. #6
    Join Date
    Mar 2006
    Posts
    121
    Tokens
    0

    Default

    Sorry for double post, but couldn't edit.

    Is it the just bits marked at the top I change because it doesn't seem to be working..

    I've put it in <script></script> tags, but it doesn't do anything. :S

  7. #7
    Join Date
    Feb 2007
    Location
    Essex, England
    Posts
    1,392
    Tokens
    0

    Latest Awards:

    Default

    Could you not use javascript to define an area, then use execCommand('Refresh', false, null); to refresh that area?

    HTML Code:
    <html>
    <head>
    <script type="Javascript">
    
    function start() {
    divname.document.designmode = 'on';
    }
    
    function refresh() {
    divname.document.execCommand('refresh', false, null);
    }
    
    </script>
    </head>
    <body onload="start()">
    
    <div id="divname" onclick="refresh()"></div>
    
    </body>
    </html>
    Not entirely sure that would work, but just a suggestion
    Last edited by L?KE; 26-04-2008 at 10:28 PM.


  8. #8
    Join Date
    Mar 2006
    Posts
    121
    Tokens
    0

    Default

    I could probably try tht yeah.. I hardly know Javascript, but I could probably mess around with it..

    Thanks!

  9. #9
    Join Date
    Mar 2006
    Posts
    121
    Tokens
    0

    Default

    Sorry for double post, couldn't edit.

    It does work, but.. I wanted it to refresh a DIV on it's on eveyr so many seconds.. where would I put an setInterval thing or whatever it's called?

Posting Permissions

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