Shoots me back to the top?

Discussion in 'jQuery' started by adamlacombe, Mar 28, 2011.

  1. #1
    I have this code here:
    
    <script type="text/javascript">
    var auto_refresh = setInterval(
    function ()
    {
    $('#load_news').load('ajax/news.php').fadeIn("slow");
    }, 10000); // refresh every 10000 milliseconds
    
    </script>
    
    Code (markup):
    It is used to refresh data coming from news.php
    How come every time it refreshes the file it shoots me back to the top of the page? is there a way to stop that from happening?
     
    adamlacombe, Mar 28, 2011 IP
  2. Jan Novak

    Jan Novak Peon

    Messages:
    121
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Could you post URL where it happens?
     
    Jan Novak, Mar 28, 2011 IP
  3. adamlacombe

    adamlacombe Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    http://datingsnap.com/index.php
    you have to login first.
    email: test@test.com
    pass: test

    You will be redirected to the user homepage. wait around 20 seconds and it will load news. Scroll down and when it refreshes the news file it shoots you back to the top of the page.
     
    adamlacombe, Mar 29, 2011 IP
  4. Jan Novak

    Jan Novak Peon

    Messages:
    121
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    0
    #4
    Adam, I have tried it in IE9 and FF4. On both browsers the scrollbar stays at the same place after refresh. Sorry, I can't simulate the error.
     
    Last edited: Mar 29, 2011
    Jan Novak, Mar 29, 2011 IP
  5. adamlacombe

    adamlacombe Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    huh thats weird, I just tried it in FF also and it didn't do that. I tried once before and it had done it in FF. I am using Google Chrome though, and it happens on there. Any idea for a fix when using Google Chrome?
     
    adamlacombe, Mar 29, 2011 IP
  6. Jan Novak

    Jan Novak Peon

    Messages:
    121
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    0
    #6
    Scrollbar ussually goes top on:
    - page refresh
    - user moves to an anchor at top,
    - or there is scrollTop

    In your case I saw scrollTop is used in chat.js, so try to look at it.
     
    Jan Novak, Mar 29, 2011 IP
  7. adamlacombe

    adamlacombe Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Nah that has nothing to do with chat.js. I had the problem even before I put the chat files on.
     
    adamlacombe, Mar 29, 2011 IP