25.11 ADD_ONLOAD_CODE Procedure
This procedure adds a javascript code snippet to the HTML output which is executed by the onload event. If an entry with the same key exists it is ignored. If p_key is NULL the snippet is always added. 
                  
Syntax
APEX_JAVASCRIPT.ADD_ONLOAD_CODE (
    p_code           IN VARCHAR2,
    p_key            IN VARCHAR2 DEFAULT NULL);
Parameters
Table 25-9 ADD_ONLOAD_CODE Parameters
| Parameter | Description | 
|---|---|
| 
 | Javascript code snippet to be executed during the onload event. | 
| 
 | Any name to identify the specified code snippet. If specified, the code snippet is added if there has been no other call with the same  | 
Example
Adds the JavaScript call initMySuperWidget()to the onload buffer. If the plug-in is used multiple times on the page and the add_onload_code is called multiple times, it is added once to the HTML output because all calls have the same value for p_key
apex_javascript.add_onload_code (
    p_code => 'initMySuperWidget();'
    p_key  => 'my_super_widget' );Parent topic: APEX_JAVASCRIPT