SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2008
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can I clear/reset the scrollbar position on refresh?

    I have the reverse problem of what most people try to do, when a user refreshes the page, I want the page to load back at the top, and not scroll back down to where the scrollbar was positioned before the refresh.

    This problem is only happening on IE7. I know I can use jscript to set the scroll bar position back to 0 on page load, but this has the ugly effect of the page loading at the top, jumping down to where the browser thinks it should go, and then onload jumping it back up to the top.

    Any thoughts? TIA

  2. #2
    SitePoint Evangelist vikrantkorde's Avatar
    Join Date
    Jun 2004
    Location
    Mumbai, India
    Posts
    541
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi jacksonheights,

    Interesting thought..
    you want to change the behavior of browser for refreshing the page on the event generated by browser and that too without using any javascript. This seems to be bit difficult unless browser allows you to do the setting saying that the refresh page must start from top and not from the location where the user is currently browsing.
    If you can give a link to refresh the page then you can do it easily. but on click of F5 or refresh button...... something to be think about
    Vikrant Korde
    S Y S T I M E, Mhape,
    Mumbai, Maharashtra, India.

  3. #3
    SitePoint Mentor NightStalker-DNS's Avatar
    Join Date
    Jul 2004
    Location
    Cape Town, South Africa
    Posts
    2,880
    Mentioned
    48 Post(s)
    Tagged
    0 Thread(s)
    I agree... y would this be needed? Plz shed some light on this scenario for us. thanks

  4. #4
    SitePoint Enthusiast
    Join Date
    May 2008
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by NightStalker-DNS View Post
    I agree... y would this be needed? Plz shed some light on this scenario for us. thanks
    The site displays a near real-time listing of links in chronological order with the newest at the top. Users often scan down the list, then refresh the browser to see the latest content at the top again. I actually did implement a refresh button to get around the issue, but its obviously quickly to just hit F5 if possible.

    I wasnt sure the javascript forum would be appropriate too. I figured its either impossible, a jscript solution or some sort of http header solution?

  5. #5
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Normally you use the fragment identifier to navigate to sections within a page.
    In this case, you can clear it to return you to the top of the page.

    Code javascript:
    location.hash = '';
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  6. #6
    SitePoint Enthusiast
    Join Date
    May 2008
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pmw57 View Post
    Normally you use the fragment identifier to navigate to sections within a page.
    In this case, you can clear it to return you to the top of the page.

    Code javascript:
    location.hash = '';
    Thanks for the idea, but trying this embedded a "#" at the end of the URL. It also did not solve the issue of the page jumping down, then jumping back up again.

  7. #7
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Then I suspect that there is nothing else that can be done to stop IE from misbehaving itself.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •