scroll position javascript

i have some script which i was hoping will remember my scroll position and move my explorer window upon asp.net postback.

<script type="text/javascript">

function scrollToC() {
  window.scrollTo(xposition,yposition);
}

function saveScrollC() {
    var xposition;
    var yposition;

 xposition = document.body.scrollLeft:window.pageXOffset;
 yposition = document.body.scrollTop:window.pageYOffset;
}
</script>

<body onload="javascript:scrollToC()">

I am getting an object expected error. I don't usualy program in javascript so I am finding it hard to de-bug.

Also are the variables in one function see in another (i.e are they public variables)?
Mr_ShawAsked:
Who is Participating?
 
Michel PlungjanConnect With a Mentor IT ExpertCommented:
And yes, you need to define the vars outside the functions to access them from other functions

var xposition;
var yposition;
function saveScrollC() {
 xposition = document.body.scrollLeft:window.pageXOffset;
 yposition = document.body.scrollTop:window.pageYOffset;
}
0
 
Michel PlungjanIT ExpertCommented:
When do you call saveScrollToC and where are the cookie or hidden form field  that remembers the position across a reload
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.