Skip to main content
Inspiring
December 21, 2016
Answered

Pausing a project when user changes over to another browser window

  • December 21, 2016
  • 2 replies
  • 466 views

Hi,

I`m using Captivate 9 and I publish in HTML5.

Is there a way to automatically pause a project if the user changes over to another browser window? And to resume the project if the user changes back to the original window (in which the course is running)?

Maybe some JavaScript solution?

Thank you very much for any help!

Best regards

Michael

    This topic has been closed for replies.
    Correct answer TLCMediaDesign

    Add this in the head of the index.html

    <script>
    function chkVisibilityChange()
    {
    if ( document.hidden )
    {
         window.cpCmndPause = 1;
       }
    else 
    {
         window.cpCmndResume = 1;
       }
    }

    document.addEventListener("visibilitychange", chkVisibilityChange, false);
    </script>

    2 replies

    Participating Frequently
    April 8, 2020

    Good morning and thanks for your support. I have a little problem, I try to synthesize.

    My client wants to avoid user open new window/program while he's watching the course.
    I have tried this code and it works perfectly only if I open new browser window.

    If I open new program (Teams, Outlook.. or a pdf) the course continues to run.

    Could you please tell me how to fix this?
    Thank you in advance.

    TLCMediaDesign
    TLCMediaDesignCorrect answer
    Inspiring
    December 22, 2016

    Add this in the head of the index.html

    <script>
    function chkVisibilityChange()
    {
    if ( document.hidden )
    {
         window.cpCmndPause = 1;
       }
    else 
    {
         window.cpCmndResume = 1;
       }
    }

    document.addEventListener("visibilitychange", chkVisibilityChange, false);
    </script>

    Inspiring
    December 22, 2016

    Great answer! Thank you very much, this is exactly what I was looking for!