tunapanda/h5p-standalone

createH5P must be passed an element

Closed this issue · 2 comments

Hi,

I have tried your project, when i call my html page, i have error "createH5P must be passed an element" on
new H5PStandalone.H5P(el, options);

In attach my html file, what am i doing wrong?
immagini.txt

your script is executed before the div is loaded into the DOM.

Easy and reliable fix is to execute the H5P logic once the DOM content is load i.e.

window.addEventListener('DOMContentLoaded',function(){

    const el = document.getElementById('h5p-container');
    const options = {
      h5pJsonPath:  '.',
      frameJs: './assets/frame.bundle.js',
      frameCss: './styles/h5p.css',
    }
  
    new H5PStandalone.H5P(el, options)

})

Hi,

Thank's.
Now it's work fine!