SitePoint Sponsor

User Tag List

Results 1 to 13 of 13

Thread: Refresh page

  1. #1
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Refresh page

    i got this code that stores and updates the coordinates i have clicked on a webpage then reloads the page again but it refreshes the whole screen is there a way to get rid of the flicker and make it look smooth this is the code:

    Chatbox frame:
    PHP Code:
    <?php
    include "global.php";
    include 
    "msgdel.php";
    ?>
    <script language="javascript" type="text/javascript">
    document.onclick = function(e){
            var e         = e ? e : window.event;
            var x = e.screenX;
            var y = e.screenY;
            document.location = 'nextpage.php?x=' + x + '&y=' + y;
        }
    </script>

    </HEAD>

    <?php
    $msgopen 
    "store/cords/x/$username.txt";
    $fh2 fopen($msgopen'r');
    $xdata fgets($fh2);
    fclose($fh2);
    ?>

    <?php
    $msgopen 
    "store/cords/y/$username.txt";
    $fh2 fopen($msgopen'r');
    $ydata fgets($fh2);
    fclose($fh2);
    ?>

    <?php
    $msgopen 
    "store/messages/$username.txt";
    $fh2 fopen($msgopen'r');
    $msgread fgets($fh2);
    fclose($fh2);
    ?>
    <div align="left">
        <table border="1" cellspacing="0" cellpadding="0" id="table1">
            <tr>
                <td style="position: absolute; left: <?= $xdata ?>; top: <?= $ydata ?>; right: <?= $xdata ?>; bottom: <?= $ydata ?>">
                <image src="images/avatar.gif"><br><image src="images/mod1.gif" width="7" height="14"><span STYLE="background-image: url(images/mod2.gif); width="1" height:14;"><? echo $username?></span><image src="images/mod3.gif" width="7" height="14"></span>
    <image src="images/msg1.gif" width="7" height="14"><span STYLE="background-image: url(images/msg2.gif); width="1" height:14;"><? echo $msgread?></span><image src="images/msg3.gif" width="7" height="14"></span>
                </td>
            </tr>
        </table>
    </div>
    Nextpage.php
    PHP Code:
    <?
    include "global.php";
    $x             $_GET['x'];
    $y             $_GET['y'];
    $myFile "store/cords/x/$username.txt";
    $fh fopen($myFile'w') or die("can't open file");
    $stringData fread($fhfilesize($myFile));
    fwrite($fh$x);
    fclose($fh);

    $myFile2 "store/cords/y/$username.txt";
    $fh2 fopen($myFile2'w') or die("can't open file");
    $stringData2 fread($fh2filesize($myFile2));
    fwrite($fh2$y);
    fclose($fh2);
    header('Location: chatboxframe.php');
    ?>
    Animated Chatrooms - www.121chatrooms.net

  2. #2
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    anyone?
    Animated Chatrooms - www.121chatrooms.net

  3. #3
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you please rephrase your question? I didn't get it.

  4. #4
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in my code above i want to refresh the page every 2 seconds with no page flicker so it looks all smoothly when it refreshes.
    Animated Chatrooms - www.121chatrooms.net

  5. #5
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,527
    Mentioned
    84 Post(s)
    Tagged
    4 Thread(s)
    Instead of refreshing the page every two seconds, you can use Ajax to send data to your server without any refreshing.

  6. #6
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i need to receive it to
    Animated Chatrooms - www.121chatrooms.net

  7. #7
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You will receive it to with Ajax. You can control if a full reload is smooth or not, that depends on how fast the browser renders the page.

  8. #8
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oh ok what would an example be on that code i have posted above?
    Animated Chatrooms - www.121chatrooms.net

  9. #9
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You will find tons of Ajax tutorials here.

  10. #10
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok i am a bit confused what ajax can do but what im trying to do is:

    i making a chat page and want the page to reload everytime a message is sent out, but i dont want any screen flicking is that possible?
    Animated Chatrooms - www.121chatrooms.net

  11. #11
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can refresh the entire page with JavaScript. If the page will flicker or not depends how fast the browser renders the page.

    With Ajax you can do a request (get or post) and update only a certain part of the page. Read the Ajax tutorials to better understand how this is done.

  12. #12
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    by saying updating only a certain part of the page, would it still flicker, i have seen other php and ajax chats refresh with no flicker and would like to know how it is done, i cant find where to find a code for it.
    Animated Chatrooms - www.121chatrooms.net

  13. #13
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,527
    Mentioned
    84 Post(s)
    Tagged
    4 Thread(s)
    Here is a tutorial that demonstrates using ajax with php

    http://www.ajaxtutorial.net/index.ph...ajax-with-php/


Bookmarks

Posting Permissions

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