Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6851715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:16:55+00:00 2026-05-27T01:16:55+00:00

I have some code where I am trying to include a script file and

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:16:56+00:00Added an answer on May 27, 2026 at 1:16 am

    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:

    function includeJS(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);
    }
    
    function checkFlash(){
        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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to implement unit testing and currently have some code that does
I have some jquery code which I am trying to translate to YUI. I
Trying to get comfortable with jQuery and I have encountered some sample code that
I am now trying to understand some code and I have found a pattern,
I am trying to reduce some code here. I will explain how I have
I am trying to setup a few fixes in some code that have caught
I have a mobile platform that I am trying to write some communications code
I'm trying to port some of my c++ code into c. I have the
I have some code for starting a thread on the .NET CF 2.0: ThreadStart
I have some code like this in a winforms app I was writing to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.