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

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

New Here ,
Jun 08, 2020 Jun 08, 2020

Copy link to clipboard


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) {

    // 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.

Advanced , Editing , Getting started







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

Have something to add?

Join the conversation