Search code examples
orbeon

Stop prompt to leave unsaved form on Form Runner


We are using Form Runner inside another web application (by loading a form into an iframe). The other web application has session timeout functionality to require the user to log back in after a certain number of minutes.

When the form is loaded in the application, the session timeout does not work (can't change the page), because Form Runner is prompting asking if the user is sure they want to leave the page (as the form is not saved).

We currently do not want to save any existing data on timeout, so don't mind that data is lost (not a very big form).

Is there a way to disable this prompting on unload?


Solution

  • Kudos to @orbeon for pointing out the file which defines the beforeUnload function.

    The prompt is created through the window beforeUnload event, which in Orbeon Form Runner is set in the check_dirty_script.xhtml. It can be easily overridden by resetting the window.onbeforeunload once the form has been loaded. To do it in your form, attach a script to the xforms-ready event:

        ...
        <xf:model...>
            ....
            <xf:action ev:event="xforms-ready">
                <xxf:script>
                    window.onbeforeunload = null;
                </xxf:script>
            </xf:action>
        </xf:model>
    </xh:head>
    <xh:body>
        <fr:view>
        ....