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
AnithaThanAnithaThan 

Unable to view Calender for Date Field Due to Window.Onload In PE

Hi Folks!!


I am developing a Visualforce Page in PE where I used a date field(Visited_Date__c) of a custom object(CCIR__c)


I am able to access the calendar of that date field initially, but after adding the window.onload in the javascript I
could not.


Please find my code snippet below:


//------------------------------------------------------------------------------------

 

<apex:page standardcontroller="CCIR__c">
    <apex:form id="myform">
        <script type="text/javascript">
        window.onload = DefaultSettings;
        function DefaultSettings()
        {
          //Default Settings  
        }
        </script>
    <apex:inputfield id="id" value="{!CCIR__c.Visited_Date__c}"/>
 </apex:form>
</apex:page>

 

//----------------------------------------------------------------------------------


Kindly suggest me with a solution for this ASAP.


Thanks in advance!!


Regards,

Sanjana

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox

Don't use OnLoad in a script like that. It is a surefire way to screw up the default loading behavior of Salesforce. This is due to the fact that onload is not a "collection" event system, such as it is in C#; assigning your own value here overrides the default load mechanism. Instead, use the attachEvent/addEventListener method:

 

 

if(window.attachEvent)
  window.attachEvent('onload',DefaultSettings)
else
  if(window.addEventListener)
    window.addEventListener('load',DefaultSettings,false)

function DefaultSettings() {
// Default settings here
}