Disabling On onbeforeunload Event in PageInit

 /**

     * Function to be executed after page is initialized.

     *

     * @param {Object} scriptContext

     * @param {Record} scriptContext.currentRecord – Current form record

     * @param {string} scriptContext.mode – The mode in which the record is being accessed (create, copy, or edit)

     *

     * @since 2015.2

     */

    function pageInit(scriptContext) {

 

        window.onbeforeunload = null

 

    }

 window.onbeforeunload = null means that you are disabling any function or code that was previously assigned to the onbeforeunload event of the window.

The onbeforeunload event in JavaScript is triggered when the user is about to close or leave the page. It is often used to display a confirmation dialog asking the user if they are sure they want to leave the page, usually to prevent accidental navigation away from a page where the user may have unsaved changes.

By setting window.onbeforeunload = null, you are removing any event handler that was set for this event, effectively disabling the confirmation prompt and allowing the user to leave the page without any interference.

Leave a comment

Your email address will not be published. Required fields are marked *