-
Book Overview & Buying
-
Table Of Contents
Visualforce Development Cookbook - Second Edition
By :
An onload handler allows JavaScript code to be executed when an HTML page has completed loading. When adding an onload handler to a Visualforce page, care must be taken not to interfere with any default onload handler added by the platform, to give focus to the first input field in the page, for example.
In this recipe, we will create a Visualforce page that allows a user to create an opportunity. An onload handler in the page executes a JavaScript function to set the default value for the opportunity amount field to 100000. If the platform has specified an onload handler function, this is executed before the amount value is set.
This recipe makes use of a standard controller, so we only need to create the Visualforce page.
Create the Visualforce page by navigating to the Visualforce setup page by clicking on Your Name | Setup | Develop | Visualforce Pages.
Click on the New button.
Enter Onload in the Label field.
Accept the default Onload that is automatically...