Skip to main content
Participant
Jul 10, 2020 6:51 PM UTC
Question

Javascript error: TypeError: Cannot read property 'contentDocument'

Within the Captivate courses I have a "Web Object" for a JotForms form that the end-user needs to complete before proceeding. 

 

Within Advanced Actions I have:

Conditional Statement - If "cpInfoCurrentFrame" is greater than "30"

Action: Pause

 

Additionally:

Action: Execute Javascript (Parent)

Javascript:

var iframe = document.getElementById("myFrame_Web_2c");
var innerDoc = iframe.contentDocument || iframe.contentWindow;
var btn = innerDoc.getElementsByClassName("form-submit-button");
btn.addEventListener("click",playCourse);
function playCourse() {
cp.movie.play(cp.ReasonForPlay.PLAYBAR_ACTION);
}

I have received TypeError: Cannot read property 'contentDocument'

when I add a Timeout function I receive var "X" undefined.

 

Any assistance is greatly appreciated.

 

    This topic is closed to new replies. Start a new post to keep the conversation going.

    2 replies

    Stagprime2687219
    Legend
    Jul 10, 2020 8:09 PM UTC

    Are you trying to test this locally?

    Without examining your code...

    Browsers are real finicky about allowing communication through an embedded iFrame as it is considered a security risk.

    If you publish to a bonafide webserver - the browser should detect that both project and iFrame are a part of the same domain and allow the communication to proceed.

    Translate
    JFKiddAuthor
    Participant
    Jul 13, 2020 11:25 AM UTC

    I have tried locally and within Saba LMS, in both scenarios I receive the following:

    TypeError: Cannot read property 'contentDocument' of null
    at eval (eval at a.runJavascript (eval at e (CPXHRLoader.js:37)), <anonymous>:2:23)
    at eval (<anonymous>)
    at Function.a.runJavascript (eval at e (CPXHRLoader.js:37), <anonymous>:862:150)
    at eval (eval at executeAction (eval at e (CPXHRLoader.js:37)), <anonymous>:1:245)
    at cp.Movie.executeAction (eval at e (CPXHRLoader.js:37), <anonymous>:1184:432)
    at cp.Movie.frameBasedExecuteAction (eval at e (CPXHRLoader.js:37), <anonymous>:1185:84)
    at a.Timeline.updateFrame (eval at e (CPXHRLoader.js:37), <anonymous>:1065:52)
    at cp.Movie._onEnterFrame (eval at e (CPXHRLoader.js:37), <anonymous>:1195:196)
    at step (eval at e (CPXHRLoader.js:37), <anonymous>:1174:23)

    Translate