JavaScript maintaining scroll position causes page to jump maintaining scroll position when adding content,maintaining scroll position between

I'm developing a web site using asp.net 2.0 and I recently added a few lines of javascript to save the scroll position of a div across postbacks.

The problem is that when the page loads the div's scroll position starts at the top and then jumps to the saved position.
How do I get rid of this jump effect? The website is located at www.collectedlight.net.

Here's the javascript that I'm using to maintain scroll position:

window.onload = function () {
   //maintain the scroll position for the list of photos across postbacks
   var scrollPos = document.getElementById('ctl00_pagePlaceHolder_photoListScrollPos').value;
   document.getElementById('photoListScrollBar').scrollTop = scrollPos;
}

//save the scroll position of the list of photos
function SaveScrollPos() {
   var scrollPos = document.getElementById('photoListScrollBar').scrollTop;
   document.getElementById('ctl00_pagePlaceHolder_photoListScrollPos').value = scrollPos;
}

The scroll position DOES get saved but as the page is loading I can see the scroll position first set to the top and then jump down to the saved scroll position. I want the page to load at the saved scroll position without the jump effect. Is this possible?

Answer:1

I am searching for something which renders an HTML template starting from a JSON file of data. The matter is that the plugin/framework/library I'm searching for must create itself the <html> ...

I am searching for something which renders an HTML template starting from a JSON file of data. The matter is that the plugin/framework/library I'm searching for must create itself the <html> ...

i am replacing the img src attribute using javascript my code is <div class="reader" id="reader1"></div> <img src="images/img_001.jpg" alt="image" id="image1"/> </div&...

i am replacing the img src attribute using javascript my code is <div class="reader" id="reader1"></div> <img src="images/img_001.jpg" alt="image" id="image1"/> </div&...

I have been working on making a form that uploads an image through ajax with php doing the upload. For some background I am having an issue where the xhr.readyState and .Status seem to run and upload....

I have been working on making a form that uploads an image through ajax with php doing the upload. For some background I am having an issue where the xhr.readyState and .Status seem to run and upload....

  1. ajax javascript with php
  2. ajax with javascript
  3. ajax with javascript example
  4. javascript ajax with parameters
  5. javascript ajax with headers
  6. ajax with javascript tutorial
  7. javascript ajax with promise
  8. javascript ajax with callback
  9. javascript ajax with json
  10. ajax with javascript or jquery
  11. javascript ajax with data
  12. javascript ajax with post
  13. javascript ajax with cookies
  14. javascript ajax with timeout
  15. ajax with javascript function
  16. javascript ajax with laravel
  17. javascript ajax with jsonp
  18. ajax with javascript html
  19. ajax javascript to php variable
  20. ajax javascript to python

This code works perfect for crome and firefox.. but error in IE8 if($('#soundcheck').is(':checked')){ //alert('checked'); var audio = document.createElement('...

This code works perfect for crome and firefox.. but error in IE8 if($('#soundcheck').is(':checked')){ //alert('checked'); var audio = document.createElement('...

  1. jquery play notification sound