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');
?>