Skip to content

Instantly share code, notes, and snippets.

@ericakfranz
Created December 7, 2015 22:11
Show Gist options
  • Save ericakfranz/d05f238d5f9e2dc1cebc to your computer and use it in GitHub Desktop.
Save ericakfranz/d05f238d5f9e2dc1cebc to your computer and use it in GitHub Desktop.
Stop a video from playing when the optin closes, then add the video url back when the optin opens - useful for Manual Trigger optins.
jQuery(document).ready( function($){
//Snag the URL of the iframe so we can use it later
var url = $('.optin_custom_html_applied iframe').attr('src');
$(document).on('OptinMonsterOnShow', function( event, data, object){
//Below we remove the URL to stop the video from playing, here we add it back in
$('.optin_custom_html_applied iframe').attr('src', url);
});
$(document).on('OptinMonsterOnClose', function( event, data, object){
//Assign the iframe's src to null, which kills the video
$('.optin_custom_html_applied iframe').attr('src', '');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment