0

I'm trying to detect flash support, and I'm trying to proceed like in this answer: Cross Browser Flash Detection in Javascript

My code is the following, but I always get the same error: swfobject is not defined. I shouldn't get that because I'm trying it in browsers that do support flash (chrome and firefox).

if(swfobject){
    console.log("you have swfobject.");

    if(swfobject.hasFlashPlayerVersion("1")){
        console.log("You have flash!");
    }
    else{
        console.log("You do not flash :(");
    }
}else{
    console.log("you don't have swfobject");
}

Is this a problem with newest browsers? Is there any other way to detect it?

3 Answers 3

2

If swfobject is not defined, you are missing the required JavaScript file. You can load via CDN here https://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js

Sign up to request clarification or add additional context in comments.

Comments

1

MDN page on flash led me through a completly diferent path:

if(navigator.mimeTypes["application/x-shockwave-flash"]){
    var plugin = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin;
    var description = plugin.description;
    var versionArray = description.match(/[\d.]+/g);
    var flashVersionOSXScriptable = 12;
    var flashVersion = parseInt(versionArray[0]);

    if(navigator.userAgent.indexOf("Mach-O")==-1){
        if(flashVersion >= flashVersionOSXScriptable){
            console.log("you have flash");
        }else{
            console.log("you don't have flash");
        }
    }
}else{
    console.log("you don't have flash");
}

Comments

0

Try checking for the typeof the object like this:

if(typeof swfobject != "undefined"){ //Check if type of the object is undefined

    console.log("you have swfobject.");

    if(swfobject.hasFlashPlayerVersion("1")){
        console.log("You have flash!");
    }
    else{
        console.log("You do not flash :(");
    }
}else{
    console.log("you don't have swfobject");
}

1 Comment

I did not mention it but the problem is that it throws the error even in browsers that do support flash!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.