browserExitWarning

Help for using specific functions

browserExitWarning

Postby John Robin Dove » Mon Feb 23, 2015 12:33 pm

Hi,

This function would be useful but I think it no longer functions in some browsers. I've tried it in Chrome, Firefox and IE but it only seems to work in IE. I've been looking here http://stackoverflow.com/questions/1119289/how-to-show-the-are-you-sure-you-want-to-navigate-away-from-this-page-when-ch but I don't know whether this could be used in TB/Powerpac.
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: browserExitWarning

Postby Clifton » Mon Feb 23, 2015 1:50 pm

Outside of IE, this function does not work very well. Browser security has made it impossible to successfully capture the window.close event. We used to be able to do this with limited success in Firefox and Chrome, but now these browsers just ignore any scripting that would display a message with the window.onbeforeunload event.

More than likely this functionality will not be reliable in IE either as time goes on, especially with the release of Windows 10 and beyond.

The real purpose behind this function was to prevent a situation wherein a student attempted to close the browser window before their course results were posted to an LMS. This function provided a way for a student to back out from their decision to close the window. However, even in the early days, while we could display the message, we could not prevent the inevitable closing of the browser window. Fortunately IE still works as of version 11 but the trigger event doesn't reach its intended target anymore.

We don't expect this function to remain in the PowerPac in future releases. In the meantime, we will continue doing some research into possible alternatives/workarounds. Anyone who has suggestions or discovers a solution is welcome to post their findings.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: browserExitWarning

Postby Clifton » Mon Feb 23, 2015 5:36 pm

UPDATE:
I was able to install some code that restored functionality so all browsers will work with this function. There are some limitations that cannot be overcome with Firefox and Chrome . . . namely that custom exit messages will not display; instead only the internal browser ones will be used.

You will need to download the latest beta to get this updated feature.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: browserExitWarning

Postby John Robin Dove » Tue Feb 24, 2015 6:50 am

Wow that was quick! Thanks very much. I have just downloaded beta 12.210. This will be useful because my system does not allow a student to do an exercise more than once in an hour. A custom warning would have been nice but this is far better than nothing at all.
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: browserExitWarning

Postby John Robin Dove » Tue Feb 24, 2015 6:59 am

Maybe I'm doing something wrong but so far I haven't made it work in Chrome and Firefox. Only IE.

UPDATE: I'm not sure what was wrong but it's now working and I can display a custom message in Chrome!
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: browserExitWarning

Postby PetrH » Sun May 08, 2016 8:15 am

I'd like to use this function with IE11. Fortunately (or not) my client requires IE browsers so I should be able to safely use this function to prevent premature exit from the book.

I'm not sure when and where I would call this function... can someone please tell me how they used it?
Peter
Always available for Toolbook work.
[email protected]
PetrH
 
Posts: 22
Joined: Mon Jan 20, 2014 11:29 pm

Re: browserExitWarning

Postby Clifton » Sun May 08, 2016 1:53 pm

You can call browserExitWarning() anywhere after the book loads. The function hooks into the window object and detect when an attempt is made to close it. The function only needs to be called ONCE to activate it. You can deactivate it's behavior by running it again with the appropriate parameters. Each browser behaves a little differently when the user attempts to close the window.

Generally, it is best to call the function once when entering content in your application that requires the behavior. For example, hen a student begins a quiz, the function could be used to discourage the student from closing the course by click the X in the browser title bar. THEN, once the quiz is complete AND results have been sent to the LMS, the function should be run again to disable its behavior to allow a normal window exit. You have to disable the function somewhere in your actions so that the student does receive the warning once the results have been handled.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am


Return to Function Help

Who is online

Users browsing this forum: No registered users and 3 guests

cron