Highlighted

Javascript error: TypeError: Cannot read property 'contentDocument'

New Here ,
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

57

Likes

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

Javascript error: TypeError: Cannot read property 'contentDocument'

New Here ,
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

58

Likes

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
Jul 10, 2020 0
Advocate ,
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.

Likes

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
Reply
Loading...
Jul 10, 2020 0
Jfkidd LATEST
New Here ,
Jul 13, 2020

Copy link to clipboard

Copied

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)

Likes

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
Reply
Loading...
Jul 13, 2020 0