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.createElement('script');
v_js.type = 'text/javascript';
v_js.src = p_file;
document.getElementsByTagName('head')[0].appendChild(v_js);
}
function checkFlash(){
includeJS('/scripts/swfobject.js');
var playerVersion = swfobject.getFlashPlayerVersion();
return playerVersion.major;
}
alert(checkFlash());
The problem is it is failing at checkFlash() where it tries to get the player version. I checked firebug and it shows the script is loaded and its reading the file correct, so its not a path issue.
I thought that maybe it was a delay issue in the includeJS function, but when I would that code in before the alert without it being a function, it still gives the same problem.
Any ideas on how I would accomplish something like this?
Thanks.