As far as I remember, the code for obtaining a position in the viewport differs between browsers, so it would be easier to use some kind of structure, for example Prototype has a document.viewport.getScrollOffsets function (which, I believe, is the one you need).
However, obtaining coordinates is only one part, the other is to do something with them later. In this case, you can add the eventener event to the window.unload event, when it fired, save the location in a cookie, and then when the user opens the page again, check if this cookie is present and scroll accordingly.
Although, if everything you care about returns the user to the place where he was when he comes to the page via the "Back in the browser" button, do most browsers not do this automatically?
source share