• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Javascript error: TypeError: Cannot read property 'contentDocument'

New Here ,
Jul 10, 2020 Jul 10, 2020

Copy link to clipboard

Copied

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.

 

Views

2.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jul 10, 2020 Jul 10, 2020

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 13, 2020 Jul 13, 2020

Copy link to clipboard

Copied

LATEST

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)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources