Jump to content

Content box (scroll bar position) after refresh problem?


Recommended Posts

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";

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.