Skip to content
Advertisement

onYouTubeIframeAPIReady function is not calling

I want to call onYouTubeIframeAPIReady function but this is not firing. I am getting only frameID in console but other functions are not getting called.

JavaScript

Advertisement

Answer

Your onYouTubeIframeAPIReady() function must be defined globaly. Simply replace the line

JavaScript

with

JavaScript

It is also important to load the youtube iframe api library file:

JavaScript

Also your iframe src url must have appended the enablejsapi=1 parameter:

JavaScript
Advertisement