When a user leaves a page, the onBeforeUnload event triggers the call to the checkDirty function. The following code fragment shows how the checkDirty function is associated with the onBeforeUnload event. The return statement indicates that checkDirty can return a value.
<body scroll="no" rightmargin="20" leftmargin="20" onBeforeUnload="return checkDirty()">
The checkDirty function returns the variable L_PageIsDirty when the isDirty flag evaluates to TRUE. L_PageIsDirty contains a localized string. The following code fragment shows the checkDirty function in the IsDirty.js file:
function checkDirty() {
if (isDirty) return L_PageIsDirty;
}
When the L_PageIsDirty string is returned to the onBeforeUnload event, the application inserts localized text into a dialog box that contains intrinsic JavaScript text. The following code fragment shows the content of L_PageIsDirty for the U.S. English version of the PT application. Coding *list.htm and Coding *.htm describe the context of this code.
var L_PageIsDirty = 'Some fields have been updated. Click Change to save your changes to the database.';
The following illustration shows the message that is displayed by inserting the contents of the L_PageIsDirty variable between the two lines of JavaScript text.