Disable 'Changes you made may not be saved' notification from browser
May 12, 2021 12:00 AM
Hello.
When exiting a module from a LMS by closing the content window, a 'Changes you made may not be saved' message may appear.
I have read that this can be disabled with a 'window.onbeforeunload = null' command.
Do you know how this can be implemented in a Lectora title ?
Thank you for your help !
Solution
@GuillaumeC As mentioned by @wheels, this extra prompt is keeping users from accidently closing the course and is along the lines of a lot of software that prompts "Are you sure you want to do this?". But there is a specific workaround for this feature:
If the author does not like the prompt when the student closes the window by either a reload or by clicking the browser window close button, they can add a JS action at the title level that On Show runs this code:
(window.myTop || window).noPromptOnUnload = true;
Discussion (5)
Thank you for your prompt reply.
I will inform my client of the "risks" involved.
Can you please confirm that the enclosed picture is the correct way to implement?
It doesn't seem to work.
Can you tell us a little more about your use case? This prompt should help ensure learners close your course properly, with an exit button. This also prevents the learner from accidentally reloading the content (on mobile if they are swiping down to scroll up and scroll to far). There are a lot of different scenarios and it would be great to hear how you host your course. Is it displayed in it's own window, or in the same window within the LMS?
If you absolutely need to disable it you would have a project level action:
Project -> On Show -> Run JavaScript
getDisplayWindow().onbeforeunload = null;
@GuillaumeC As mentioned by @wheels, this extra prompt is keeping users from accidently closing the course and is along the lines of a lot of software that prompts "Are you sure you want to do this?". But there is a specific workaround for this feature:
If the author does not like the prompt when the student closes the window by either a reload or by clicking the browser window close button, they can add a JS action at the title level that On Show runs this code:
(window.myTop || window).noPromptOnUnload = true;
This is the correct way to disable the prompt:
If the author does not like the prompt when the student closes the window by either a reload or by clicking the browser window close button, they can add a JS action at the title level that On Show runs this code:
(window.myTop || window).noPromptOnUnload = true;
We recently moved to Docebo and our Lectora courses would no longer resume correctly.
Your JS code worked perfectly. Thank you!