sync2007 Posted April 23, 2007 Share Posted April 23, 2007 I created a content box with a scroll bar, in this page i used a meta tag to refresh the page every 5 seconds in order to retrieve new data from database. Now the problem is that when there is a lot of text in the content and i move the scroll bar down it returns to the top when the page is refreshed. so how can i solve this problem? here is my content box: #contentbox { position: absolute; top: -11px; right: 15px; margin: 20px; background: #E5E5E5; padding: 5px; width: 200px; height: 320px; overflow: auto; } here is my meta tag: <meta http-equiv="refresh" content="5;url=shoutbox.php" > and here is the code for inserting data into the content box: echo "<div id=\"contentbox\">\n"; $query2 = "SELECT distinct chatter from shout_log order by id desc "; $result2 = mysql_query($query2); while($rows=mysql_fetch_array($result2)){ echo " $rows['chatter'] "; } echo "</div>\n"; Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted April 24, 2007 Share Posted April 24, 2007 firstly - if this is a site for people to use the refresh will be infuriating! this is a job for ajax - you can 'invisibly' retrieve new data without a whole new header being sent. the retrived info can also be appended to the content without page reload and depending on whether you prepend or append the new data th user will not scroll away from the current info. Check the ajax forum for help on this. I will place an example on there if you are still struugling later on. BUT here is (probably) ALL you will ever need for ajax http://rajshekhar.net/blog/archives/85-Rasmus-30-second-AJAX-Tutorial.html Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.