Create Script Tag Within Javascript And Call Function Right After
I have some code where I am trying to include a script file and then call a function inside the script file. The code is: function includeJS(p_file) { var v_js = document.cre
Solution 1:
I think your problem is that the script file doesn't finish loading before you attempt to check the player version (just like you originally thought). You might want to try this:
functionincludeJS(p_file, callback) {
var v_js = document.createElement('script');
v_js.type = 'text/javascript';
v_js.src = p_file;
v_js.onreadystatechange = callback;
v_js.onload = callback;
document.getElementsByTagName('head')[0].appendChild(v_js);
}
functioncheckFlash(){
var playerVersion;
includeJS('/scripts/swfobject.js', function () {
var playerVersion = swfobject.getFlashPlayerVersion();
alert(playerVersion.major);
});
}
checkFlash();
This is a modified version of the solution presented in the accepted answer to this similar question.
Post a Comment for "Create Script Tag Within Javascript And Call Function Right After"