cant initialize CodoPlayer

cant initialize CodoPlayer

Postby bortolazzie » Thu Feb 20, 2014 5:22 pm

Good evening,
i wrote this code on my js file:
Code: Select all
var div = document.getElementById(this.target),
     script = document.createElement('script');
    
     script.type = "text/javascript";
     script.src = "http://pbsiwebsite.dev-p25-enrico.diffusionetessile.it/Scripts/CodoPlayer/CodoPlayer.js";
    
     div.appendChild(script);
    
     player = CodoPlayer('WGt-8adyabk',{engine:'youtube',width: 600,height: 338});


but when i execute the scripts it return this:
Code: Select all
 player = CodoPlayer('WGt-8adyabk',{engine:'youtube',width: 600,height: 338});
SecurityError: The operation is insecure.
   

Filtered chrome url chrome://firebug/content/console/commandLineExposed.js


how can i use api to create a player with a youtube video?
bortolazzie
 
Posts: 1
Joined: Thu Feb 20, 2014 5:19 pm

Re: cant initialize CodoPlayer

Postby donatas » Thu Feb 20, 2014 5:34 pm

Hi,

To initialise the script, you must first listen for the script "onload" method in order to be sure that "CodoPlayer.js" is fully loaded before firing the caller method.

For example:
Code: Select all
var script = document.createElement('script');
script.onload = function() {
    player = CodoPlayer('WGt-8adyabk',{engine:'youtube',width: 600,height: 338});
};
script.src = "http://whatever.com/the/script.js";
document.getElementsByTagName('head')[0].appendChild(script);

Good luck!
donatas
Site Admin
 
Posts: 18
Joined: Sun Aug 18, 2013 12:01 pm


Return to API



cron