Youtube Iframe: OnYouTubePlayerAPIReady() Not Called February 01, 2023 Post a Comment I have a page with an iframe which load a youtube video (the src of iframe is modified in runtime). I based on code by Rob W provided in different answers on this topic Solution 1: onYouTubePlayerAPIReady should be on the window object. try: window.onYouTubePlayerAPIReady = function() { alert('called onYouTubePlayerAPIReady'); ytIframeplayer = new YT.Player('browser', { events: { "onStateChange": stopCycle } }); } Copy Solution 2: It seems like you're not closing the functions off correctly. The last } is closing off onYouTubePlayerAPIReady(), not dispose_ytplayer().Baca JugaIs There A Way Hide Elements In Iframe Src Page?How To Make Iframe With Svg "focusable"Difficulty Setting Focus On Newly Created Object In Javascript Fixed code: function dispose_ytplayer() { (function(){ var s = document.createElement("script"); s.src = "http://www.youtube.com/player_api"; var before = document.getElementsByTagName("script")[0]; before.parentNode.insertBefore(s, before); })(); alert('called yt_dispose'); var ytIframeplayer; function onYouTubePlayerAPIReady() { alert('called onYouTubePlayerAPIReady'); ytIframeplayer = new YT.Player('browser', { events: { "onStateChange": stopCycle } }); } } Copy Share You may like these postsGoogle + And Facebook Style Iframe Youtube Video. By Default Shows Video Image, When Image Clicked Video PlaysIframe Has No Defined Request Full Screen MethodMeteor/mongodb See Available Fields For Publish?Youtube - Don't Display Context Menu On Right Click Post a Comment for "Youtube Iframe: OnYouTubePlayerAPIReady() Not Called"
Post a Comment for "Youtube Iframe: OnYouTubePlayerAPIReady() Not Called"