Skip to content

Commit

Permalink
fix: inject jQuery property into Iframe window #74 (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
murage authored Apr 19, 2021
1 parent 7db44f2 commit 1ec9101
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/main.bundle.js

Large diffs are not rendered by default.

27 changes: 24 additions & 3 deletions src/js/h5p-standalone.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,30 @@ export default class H5PStandalone {
throw new Error('createH5P must be passed an element');
}

el.innerHTML = `<div class="h5p-iframe-wrapper" style="background-color:#DDD;">
<iframe id="h5p-iframe-${this.id}" class="h5p-iframe" scrolling="no" data-content-id="${this.id}" style="width: 100%; height: 100%; border: none; display: block;" src="about:blank" frameBorder="0"></iframe>
</div>`;
const parent =document.createElement('div');
parent.classList.add('h5p-iframe-wrapper');
parent.style.backgroundColor='#DDD;';


const iframe = document.createElement('iframe');
iframe.id = `h5p-iframe-${this.id}`;
iframe.src='about:blank';

iframe.classList.add('h5p-iframe');
iframe.setAttribute('scrolling','no');
iframe.setAttribute('data-content-id',`${this.id}`);

iframe.setAttribute('frameBorder',0);
iframe.style.width='100%'
iframe.style.height='100%'
iframe.style.border='none'
iframe.style.display='block'

parent.append(iframe);
el.append(parent);

// inject jQuery property to avoid fatal error if required
iframe.contentWindow['jQuery'] ={}
}

async initH5P(frameCss = './styles/h5p.css', frameJs = './frame.bundle.js', displayOptions, preventH5PInit) {
Expand Down

0 comments on commit 1ec9101

Please sign in to comment.