MaintainScrollPositionOnPostBack.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. function WebForm_SaveScrollPositionSubmit() {
  2. theForm.elements['__SCROLLPOSITIONX'].value = WebForm_GetScrollX();
  3. theForm.elements['__SCROLLPOSITIONY'].value = WebForm_GetScrollY();
  4. if ((typeof(this.oldSubmit) != "undefined") && (this.oldSubmit != null)) {
  5. return this.oldSubmit();
  6. }
  7. return true;
  8. }
  9. function WebForm_SaveScrollPositionOnSubmit() {
  10. theForm.elements['__SCROLLPOSITIONX'].value = WebForm_GetScrollX();
  11. theForm.elements['__SCROLLPOSITIONY'].value = WebForm_GetScrollY();
  12. if ((typeof(this.oldOnSubmit) != "undefined") && (this.oldOnSubmit != null)) {
  13. return this.oldOnSubmit();
  14. }
  15. return true;
  16. }
  17. function WebForm_RestoreScrollPosition() {
  18. window.scrollTo(theForm.elements['__SCROLLPOSITIONX'].value, theForm.elements['__SCROLLPOSITIONY'].value);
  19. if ((typeof(theForm.oldOnLoad) != "undefined") && (theForm.oldOnLoad != null)) {
  20. return theForm.oldOnLoad();
  21. }
  22. return true;
  23. }
  24. function WebForm_GetScrollX() {
  25. if (window.pageXOffset) {
  26. return window.pageXOffset;
  27. }
  28. else if (document.documentElement && document.documentElement.scrollLeft) {
  29. return document.documentElement.scrollLeft;
  30. }
  31. else if (document.body) {
  32. return document.body.scrollLeft;
  33. }
  34. return 0;
  35. }
  36. function WebForm_GetScrollY() {
  37. if (window.pageYOffset) {
  38. return window.pageYOffset;
  39. }
  40. else if (document.documentElement && document.documentElement.scrollTop) {
  41. return document.documentElement.scrollTop;
  42. }
  43. else if (document.body) {
  44. return document.body.scrollTop;
  45. }
  46. return 0;
  47. }