add javascript to content inside iframe


I have a drupal 7 site where I use h5p module.

How could I add external js file inside the iframe where the interactive content is (question set)?

I have managed to modify the embed.php file, and that works when the interactive content is embedded manually to a page.

But I think the embed.php file is not used when the h5p content is shown normally on a interactive content page.

Is there a file like embed.php which to modify to add a javascript?

The script which I need to add in the iframe is google analytics tracking script.

Thank you for a great module.

otacke's picture

Hi Jukka79!

Scripts can be added in h5p.js. You're modifying the core of H5P here, so I hope you are sure what you're doing.


I've been trying to disable the right-click context menu in the audio player. I added this code to the end of h5p.js:

  jQuery(function() {
        jQuery(this).bind("contextmenu", function(event) {
            alert('Right click disable in this site!!')

I've verified this code works-- everywhere in the frame except in the audio player. I did test it elsewhere successfully.

I also tried adding oncontextmenu="return false;" to the audio tag in debug mode as below. that works but I don't see how to change that in h5p

<audio class="h5p-audio" controls="" preload="auto" style="display: block; width: 100%;" oncontextmenu="return false;"><source src="pathto.mp3" type="audio/mp3"></audio>

Any thoughts how to get there form here?  thanks.