1

I am new to javascript and more entrenched in the front-end development side. I have found some help here with my question below - Prevent automatic browser scroll on refresh - but I have a different scenerio - one that incorporates a page refresh. This example works, but once the page refreshes, the page goes back to the top,

Scenerio: Our web app asks a series of questions, state, height, weight, gender, etc. Then a calculate button is clicked which will display the results of user's answers based on rules that are set on the back end. All of the page content displays on the same page. The results side is in a disabled mode until the questions are answered and the calculate button is clicked.

Here's what currently happens: User answers questions, calculate button is clicked, spinner displays for around 5 seconds to load results from the backend. After the results load, the page refreshes and goes back to the top of the page content with all the questions that the user just answered. User now has to scroll down to view results.

Here's what I want to happen: Calculate button is clicked, page moves down to results position and stays there AFTER the page refresh.

How can I use javascript like in the link example above to get to a specific page position after the page refreshes? Any help is greatly appreciated.

Community
  • 1
  • 1
Jen
  • 21
  • 3
  • Can you use jQuery? This question may help you: http://stackoverflow.com/questions/9757625/jquery-how-to-scroll-to-certain-anchor-div-on-page-load It may be easier to simply reload the page and then move the user instantly down to the results, unless that is not the desired effect. – Shaun Aug 09 '13 at 16:27
  • Thanks! I will check this out. I think that option can work by reloading then moving down. – Jen Aug 09 '13 at 16:30
  • 1
    How about using the XMLHttpRequest Object so that the results of the calculation can inserted into the results position without reloading the page? – jing3142 Aug 09 '13 at 16:44
  • Thanks for the responses. I can get this to work using this answer [link](http://stackoverflow.com/questions/7035331) - but it just goes back to the top after the refresh. The XMLHttpRequest Object is something I don't have experience with, but I can show my team mates and see what they think. – Jen Aug 09 '13 at 17:08

0 Answers0