IE11 JavaScript (error: SCRIPT445) "The object does not support this action"

I am using a Javascript solution that asynchronously loads the YouTube player API. When watching a video, the entire script should be played on the screen. It works in all browsers, as well as in IE (11), but sometimes in IE. I get an error in Developer Tools: SCRIPT445 (Object does not support this action).

Youtube Player still works, but it seems to break other scripts. I looked around the Internet as well as here on Stackoverflow. There seem to be others who have similar problems, but they were too specific. Maybe someone can help me with this. Here is the piece of code that creates the problem:

var yt_int, yt_players={}, initYT = function() { $(".ytplayer").each(function() { yt_players[this.id] = new YT.Player(this.id); <-- Error line }); }; $.getScript("//www.youtube.com/player_api", function() { yt_int = setInterval(function(){ if(typeof YT === "object"){ initYT(); clearInterval(yt_int); } },500); }); 
+7
javascript youtube internet-explorer-11
source share
2 answers

IE has a race condition that disables your script loader callback before the entire script is evaluated. Using setTimeout (initYT, 0), you allow the script to complete the evaluation before running the initialization function. Glad it worked!

+4
source share

the object does not support this action, an error appears in IE11 using window.dispatchEvent (new event ('resize')); we need to handle the condition for ie11.

  if (navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > 0) { var evt = document.createEvent('UIEvents'); evt.initUIEvent('resize', true, false, window, 0); window.dispatchEvent(evt); } else { window.dispatchEvent(new Event('resize')); } 
+2
source share

All Articles