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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Michel PlungjanIT 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JScript

From novice to tech pro — start learning today.