Eliminate flickering on fresh?

Discussion in 'JavaScript' started by twilitegxa, Jun 29, 2010.

  1. #1
    I have seen in some examples online that JavaScript can be used to eliminate the flickering effect when an iframe is refreshed, but I cannot figure out how to do it. Can anyone help? I have a chatroom but I don't want the page to flicker when the chatlog refreshes to show the new chat messages. Can anyone walk me though how to do this step by step? Here is the frames page:

    chatframe.php:
    
    <?php
    
    print "<iframe src='chatlog.php'  name='chatlogframe' width='350' height='400'></iframe>";
    
    print "<br><br>";
    
    print "<iframe src='submit.php' width='380' height='180' frameborder='0' scrolling='no'></iframe><br><br>";
    
    
    ?>
    
    Code (markup):
    And here is the chatlog page:
    
    <?php
    
    include "connect.php";
    
    $getnummessages="SELECT COUNT(*) as messagecount from chatmessages";
    
    $getnummessages2=mysql_query($getnummessages) or die("blah");
    
    $getnummessages3= mysql_result($getnummessages2, 0);
    
    if($getnummessages3>21)
    
    {
    
      // $startrow=$getnummessages3-20;
      $startrow=1;
    
    }
    
    else
    
    {
    
      $startrow=1;
    
    }
    
    $getmsg="SELECT name, message from chatmessages order by postime ASC limit $startrow,$getnummessages3";
    
    $getmsg2=mysql_query($getmsg) or die(mysql_error());
    
    while($getmsg3=mysql_fetch_array($getmsg2))
    
    {
      $message = $getmsg3['message'];
      $message=Smiley($message); //Smiley faces
    
       print "<font color='red'><b>$getmsg3[name]:</b></font> $getmsg3[message]<br>";
    
    
    
    }
    
    
    
    function Smiley($texttoreplace)
    
    {
    
        $smilies=array( 
    
        
    
        
    
        ':)' => "<img src='images/smile.gif'>",
    
        ':blush' =>"<img src='images/blush.gif'>",
    
        ':angry' =>"<img src='images/angry.gif'>",
    
        ':o'=>     "<img src='images/shocked.gif'>",  
    
        'fuck'=>"$#$%",
    
        'Fuck'=>"&$#@"
    
      
    
     
    
        );
    
    
    
        $texttoreplace=str_replace(array_keys($smilies), array_values($smilies), $texttoreplace);
    
        return $texttoreplace;
    
    }
    
    ?>
    
    <!--<script>
    
      setTimeout("window.location.replace('chatlog.php')",2000);
    
    
    
    </script>-->
    
    Code (markup):
    I had a refresh, but it is commented out because it causes the page or iframe to flicker. Can anyone help me stop the flickering??
     
    twilitegxa, Jun 29, 2010 IP