If you have been using Oracle Application Express for a while you will have applications that were created in a previous version.  When you upgrade to the latest release of APEX you may want to remove references to legacy JavaScript functions that have been replaced by newer functionality. 

Why remove references to legacy functions? 

  1. To avoid any security implications that may discovered in the future (Legacy functions may not be patched by Oracle).
     
  2. To reduce the size of JavaScript files loaded per page view.  Legacy functions are defined in a JavaScript file called legacy.js which included in each page load.

How do I replace a legacy function?

The legacy.js file includes commented lines that may give hints to newer AEPX namespaced functions that will replace the legacy function.

A common legacy function used in legacy APEX applications is confirmDelete.  

Use the seach application textbox in the upper right of the application builder to search for occurances where confirmDelete is used in an application.

A report is displayed showing the occurances of the search text.  Click the "View" link to edit the component.  In this example, the confirmDelete function is called as part of the URL Target of a button action.

Change the URL Target from:

 

javascript:confirmDelete(htmldb_delete_message,'DELETE');

 

to:

 

javascript:apex.confirm(htmldb_delete_message,'DELETE');

 

P.S.

The first parameter to the function, htmldb_delete_message, is a JavaScript variable usually defined in the page definition.  It should work to leave it as it is, but a little clean up can be done.  Earlier versions of APEX defined and set the value of the variable in the page definition HTML Header field.  

Copy the variable declaration and assignment line to the "Function and Global Variable Declaration" field located in the JavaScript section of the page definition.  Clear the extraneous code from the "HTML Header" field.

P.P.S

The JavaScript variable to defined to an APEX shortcut, DELETE_CONFIRM_MSG.  APEX shortcuts are defined and managed via an application's shared components > User Interface > Shortcuts.

How do I tell APEX not to load the legacy.js JavaScript file?

Change the "Include Legacy Javascript" option from "Yes" to "No".  The option is found by navigating to the application's shared components, selecting the "User Interface Attributes" link, then navigating to the JavaScript section.

 

Common legacy functions & replacement

confirmDelete >> apex.confirm
doSubmit >> apex.submit
popupFieldHelp >> apex.theme.popupFieldHelp

 

 

APEX 4.2 / 4.2.4