i have iframe embed code of youtube video and i want to auto load javascript after each iframe. i using wordpress.
I want to create this - when the user open any post/page in my wordpress website, if the post/page contain any iframe then javascript auto load after each iframe.
this is javascript which i want to load after iframe.
<script src="https://apis.google.com/js/platform.js"></script>
<script>
function onYtEvent(payload) {
if (payload.eventType == 'subscribe') {
// Add code to handle subscribe event.
} else if (payload.eventType == 'unsubscribe') {
// Add code to handle unsubscribe event.
}
if (window.console) { // for debugging only
window.console.log('YT event: ', payload);
}
}
</script>
<div class="g-ytsubscribe" data-channelid="UC_Lmg76m-DMN_EVURz_G9zw" data-layout="full" data-count="hidden" data-onytevent="onYtEvent"></div>
this is iframe
<iframe width="560" height="315" src="https://www.youtube.com/embed/blablabla" frameborder="0" allowfullscreen></iframe>