function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

scrolling the page



I have the below vf page as below. When I click the section label ({!section.Section_Label__c}) it would rerender questiondetail block and the page should scroll with top being the data from reender but when I click if I try to scroll to any componenet in the questiondetail block it didnt work,so I had to do it the way below which just shifts littlle not to the start of the data below button.I think it may be because it takes time for data to come from backend.

Q1)Is there any other way I can scroll to the data below save button.

Q2)Is there a way to have some event fire only when the data is completely loaded into the frontend and than scroll or do something.


<script language="JavaScript" type="text/javascript">

function scrollWin() {
window.scrollTo(0, 800);



<apex:form id="templateForm">

<apex:pageBlock >

<apex:pageBlockSection id="sectionBlock" title="{!templateName}" columns="1">
<apex:repeat value="{!sectionsStatusLists}" var="section">
<apex:commandLink reRender="questiondetail" onclick="scrollWin()">
<apex:param name="sectionId" value="{!sectionid}"/>

<apex:outputPanel id="questiondetail" >
<apex:pageBlock id="block1">

function focu(){
var e = document.getElementById('{!$Component.buttons1.button1}');
//var e = document.getElementById('thePage:templateForm:questiondetail:block1:buttons1:button1');
<apex:pageBlockButtons location="bottom" id="buttons1" >
<apex:commandButton value="Save" action="{!Save}"  id="button1"/>

<apex:repeat value="{!questionsList}" var="question" >

<apex:pageBlockSection columns="1" rendered="{!question.newquestFormat.Question_Type__c=='Text'}" >

<apex:pageBlockSectionItem >
<apex:outputField value="{!question.Subquestion_Label__c}" />
<apex:inputTextarea style="" rows="6" cols="100" id="textInfo" value="{!question.resObj.Response__c}"></apex:inputTextArea>

<apex:pageBlockSection columns="1" rendered="{!question.Question_Type__c=='RadioPicklist'}" >
<apex:outputPanel rendered="{!NOT(ISNULL(question.HelpText__c))}"><b>Q.{!qnum} {!question.Question_Label__c}</b><span class="helpButton" id="help1_Help"><img src="/s.gif" alt="" class="helpIcon" title="{!question.newquestFormat.HelpText__c}"/></span>

<apex:pageBlockSectionItem >
<apex:selectRadio layout="pageDirection" id="qOptionList" value="{!question.resObj.Response__c}">
<apex:selectOptions value="{!question.optionsList}"/>




Best Answer chosen by Admin (Salesforce Developers) 

Perhaps the page hasn't finished rendering.  Did you try using oncomplete instead of onclick in your commandLink?