Highlighted

Need help replacing inline JavaScript (onclick, onmouseover...)

New Here ,
Jun 08, 2020

Copy link to clipboard

Copied

In order to support a strict content security policy, I need to replace the inline onclick, etc., events with "addEventListener".  I am having limited success when modifying "constructDIVs()" in index_scorm.html.  (If there is a way to do this without editing the HTML files, I would love to hear it.).  Thanks in advance.

 

function constructDIVs() {
  if(lCSSLoaded && lJSLoaded) {
    initializeCP();

    // my additions here:

   // no error

   document.getElementById("div_Slide").addEventListener("click", cp.handleClick(event));

   // no error

   document.getElementById("playImage").addEventListener("keydown", cp.CPPlayButtonHandle(event));

   // fails

    document.getElementById("playImage").addEventListener("click", cp.movie.play());

   // fails

    document.getElementById("cc").addEventListener("click", cp.handleCCClick(event);

   // no error

   document.getElementById("ccClose").addEventListener("click", cp.showHideCC());

  }
}

 

All envent handlers were copied directly from the document.innerHTML statement, so I'm not sure what is going on here.

playImage returns:  index_scorm.html:147 Failed to execute 'addEventListener' on 'EventTarget': The callback provided as parameter 2 is not an object. 

FYI, I displayed the value of cp.movie, and it was "[object Object]".

 

cc returns:  index_scorm.html:155 Failed to execute 'elementFromPoint' on 'Document': The provided double value is non-finite.

Topics

Advanced, Editing, Getting started

Views

94

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

Need help replacing inline JavaScript (onclick, onmouseover...)

New Here ,
Jun 08, 2020

Copy link to clipboard

Copied

In order to support a strict content security policy, I need to replace the inline onclick, etc., events with "addEventListener".  I am having limited success when modifying "constructDIVs()" in index_scorm.html.  (If there is a way to do this without editing the HTML files, I would love to hear it.).  Thanks in advance.

 

function constructDIVs() {
  if(lCSSLoaded && lJSLoaded) {
    initializeCP();

    // my additions here:

   // no error

   document.getElementById("div_Slide").addEventListener("click", cp.handleClick(event));

   // no error

   document.getElementById("playImage").addEventListener("keydown", cp.CPPlayButtonHandle(event));

   // fails

    document.getElementById("playImage").addEventListener("click", cp.movie.play());

   // fails

    document.getElementById("cc").addEventListener("click", cp.handleCCClick(event);

   // no error

   document.getElementById("ccClose").addEventListener("click", cp.showHideCC());

  }
}

 

All envent handlers were copied directly from the document.innerHTML statement, so I'm not sure what is going on here.

playImage returns:  index_scorm.html:147 Failed to execute 'addEventListener' on 'EventTarget': The callback provided as parameter 2 is not an object. 

FYI, I displayed the value of cp.movie, and it was "[object Object]".

 

cc returns:  index_scorm.html:155 Failed to execute 'elementFromPoint' on 'Document': The provided double value is non-finite.

Topics

Advanced, Editing, Getting started

Views

95

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

Have something to add?

Join the conversation