Skip to main content
Inspiring
Dec 21, 2016 10:35 PM UTC
Answered

Pausing a project when user changes over to another browser window

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 is closed to new replies. Start a new post to keep the conversation going.
    TLCMediaDesign
    TLCMediaDesignCorrect answer
    Inspiring
    Dec 22, 2016 10:47 AM UTC

    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>

    3 replies

    Participating Frequently
    Apr 8, 2020 10:21 AM UTC

    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.

    Translate
    TLCMediaDesign
    TLCMediaDesignCorrect answer
    Inspiring
    Dec 22, 2016 10:47 AM UTC

    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>

    Translate
    Inspiring
    Dec 22, 2016 12:21 PM UTC

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

    Translate