Youtube Iframe: OnYouTubePlayerAPIReady() Not Called April 14, 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 JugaUnsafe Javascript Attempt To Access Frame In Google ChromeFill Input Text Forms On Other Website In IframeProxying A Site To Be Able To Wysiwyg Edit In Iframe - How Does It Work? 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 postsYoutube Iframe Player Api Failed To Execute Postmessage On DomwindowHow To Add A Button To Play Youtube Video Full Screen Using Javascript?Get Youtube Video Id From Iframe VideoPlay Html5 Video And Pause At Specific Points In Time Post a Comment for "Youtube Iframe: OnYouTubePlayerAPIReady() Not Called"
Post a Comment for "Youtube Iframe: OnYouTubePlayerAPIReady() Not Called"