I have a problem with my web pages. Its not necessarily PHP, but everything. I am trying to emulate pressing the F5 key every 10 sec on a web page. With the http-equiv, it reloads the page back to the top, and the user loses where he/she was in the page. I have tried refreshperiodic JS and it does the same thing. Is there any other options to just F5 emulate without totally reloading the page as the above examples do?

Brad

    I guess it depends what you are trying to acheive. Do you have database data which needs to be reloaded?

    Can you put the work which needs to be refreshed into an iframe and have the javascript refreshing just the iframe? If you structure your page well your user's won't even know it's there.

    Or, if the content is distributed over the page and therefore iframe won't work you can have a hidden frame with an onload javascript event which reaches out to the visible frame and transfers data from it's form fields to the visible form fields.

      In the general case (where the bits that need refreshing can't be boxed into iframes), it's pretty much a contradiction in terms - a refresh is just another name for a reload.

        You know those pages like geocities that keep a layer on the page as you scroll? Do it like that.

        Basically, you get the DOSC (document offset scroll co-ordinates)

        Then, when you refresh, you feed that value back to your script:

        The value is either:
        --IE --
        var dosc=document.body.scrollTop;
        -- Netscape --
        var dosc=window.pageYOffset;

        setTimeout("this.location.href='page.php?dosc=' + dosc",10000);

        Then, in page.php, javascript scrolls back there:

        self.scrollTo(0,<?php echo $dosc; ?>);

        Check out this URL:

        http://javascriptkit.com/javatutors/static2.shtml

        Gimme an email and let me know how it went 🙂 It's untried and untested.
        phpboi@spacecat.com

          Write a Reply...