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
RichardR1RichardR1 

VF Page: Why does the cursor land on a specific custom date field by after page load?

Does anyone know why the cursor always lands on the same field whenever the page is loaded or reloaded? I have other Visualforce pages and other fields on the page but the cursor always lands on it.

User-added image
<apex:page standardController="Interview__c" sidebar="false" >
   <apex:form >
   <apex:pageBlock mode="maindetail" >
      
      <apex:pageBlockSection columns="3">
      
            <apex:pageBlockSectionItem dataStyle="background-color:#0E2D46"> <apex:outputText ></apex:outputText> </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem dataStyle="width:100%;text-align:center;background-color:#0E2D46;color:white;padding:7px">
                <apex:outputText > <b> Table Stakes </b></apex:outputText> </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem dataStyle="background-color:#0E2D46"> <apex:outputText ></apex:outputText> </apex:pageBlockSectionItem>
             
            <apex:pageBlockSectionItem dataStyle="vertical-align:middle;width:40%;text-align:center;background-color:#0E2D46;color:white">
                <apex:outputText > <b> Candidate's Search Status </b></apex:outputText> </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem dataStyle="width:40%;text-align:center">
                <apex:inputField value="{!Interview__c.Search_Status__c}"/> </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem dataStyle="width:20%;text-align:center">
                <apex:inputField value="{!Interview__c.StatusLogDate__c}" /> </apex:pageBlockSectionItem>

      </apex:pageBlockSection>

   </apex:pageBlock>
   <div align="center"> <apex:commandButton action="{!quicksave}" value="Save" /> </div>
   </apex:form>
</apex:page>

 
Best Answer chosen by RichardR1
AbhinavAbhinav (Salesforce Developers) 
Hi Richard,

Check this

https://help.salesforce.com/articleView?id=000334695&type=1&mode=1

This article relates to a scenario where a Visualforce page has an input text field which is added to a standard page layout.
When the page layout page is loaded, the focus of the page shifts to the input text field in the VF page and not the top of the page

There could be a scenario as follows:
A Visualforce page has one or more input text fields
The Visualforce page is added to an object's standard view page layout in a section 
When the view page is loaded, the focus of the page shifts to the input text field and not the top of the page
This is a standard behavior. When a page loads, the Visualforce page finds an appropriate field to focus on based on tab indexes.

Resolution

To avoid the focus to shift to the input text field, the VF page code can be modified to have a simple Javascript code which would use the window.scrollTo function on the window.onload to shift the focus to the desired place. 

For example, this is a sample code that can be used.
<script>
    window.onload = function(){
        window.scrollTo(0,0);
    };
</script>

If it helps please mark it as best answer.

Thanks!