Monday, March 4, 2013

Go straight to the top!

Our XPages application provides a dynamically generated list of fields that are swapped out as the user navigates and/or saves their data.

We discovered that doing a partial refresh did not automatically move the user to the top of the next "page" so with a little Googling I found this bit of JavaScript that resolved the problem in short order.

Here is the code and the event handler we are using to do this:


window.scrollTo(0,0)


<xp:eventHandler event="onClientLoad" submit="false">
<xp:this.script><![CDATA[window.scrollTo(0,0)]]></xp:this.script>
</xp:eventHandler>