Hi I have lengthy custom form, wher user can select some field, when he submit the another page block except this list of fields refreshes and shows the list of batch classes at bottom of the page.

but when the user submits, the pageblock gets refreshed and it go to the top of the page , but i want that to scroll down to the bottom of the page automatically where my another pageblock resides.

i found the snippet of java script function which works fine on page load, but i want it to happen conditionally on button click.

function Scrolldown() {
window.onload = Scrolldown;

below is my command button

  <apex:commandButton value="  Submit  " action="{!docSubmit}" onclick="return confirmSubmit()" />

i added the oncomplete to my button and called the js function it didnt work.

Or any suggestion where i can do this with my Visualforce - attributes/Label/Goto like concepts or with my apex code.

1 Answer 1

    oncomplete="scrollSomewhere()" />

someAreaById should be the area to be refreshed; you can can give the form itself an Id and rerender the entire form. This is usually what I do if I can't readily determine which parts of the form may be affected. Other times, I can, and I rerender just a small part of the form. It will load much faster this way. scrollSomewhere() should be a function to write to scroll to a certain area. It could be window.scroll, or HTMLElement.scrollIntoView, which is supported on all modern browsers. You could query the element to scroll to by Id or some other attribute.

function scrollSomewhere() {

If the element is a Visualforce element, the ID value will be modified, so you should use the $Component global variable to correctly identify the component, and you'll also need to escape the ":" with \3a for a proper match:


JavaScript requires \\ to represent a literal \, and the formula tool requires \\ to represent a literal \, so you end up double-escaping the \3a required by CSS.

  • Thanks, This is really helpful with scorlling a big page to any required section. since i have to go bottom of page after clicking on button, I did in another simple way. Jul 17, 2014 at 6:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .