add javascript to content inside iframe
Submitted by jukka79 on Mon, 08/20/2018 - 03:14
Forums:
Hi,
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
Tue, 08/28/2018 - 09:27
Permalink
Hi Jukka79!Scripts can be
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.
Cheers,
Oliver
nvcacademy
Thu, 02/28/2019 - 22:30
Permalink
Javascript inside frame to disable right-click context menu
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(document).ready(function(){
jQuery(function() {
jQuery(this).bind("contextmenu", function(event) {
event.preventDefault();
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.