Skip to main content
April 5, 2017
Question

What is the best method for detecting that flash will load across browsers?

  • April 5, 2017
  • 1 reply
  • 646 views

Hi,

I'm aware that we can always use navigator.plugins to check for the presence of flash in most browsers. However, if the 'Shockwave Flash' plugin is there, is it safe to assume that a swf object will always load successfully? It appears to be the case thus far -- however is it safe to additionally inject a test SWF object into the DOM to see if it loads correctly?

For example:

function createFlashDetectObject() {

        const obj = document.createElement('object');

        obj.id = 'flashCheck';

        obj.setAttribute('type', 'application/x-shockwave-flash');

        document.body.appendChild(obj);

        obj.style.position = 'absolute';

        obj.style.left = '-999px';

        obj.style.top = '-999px';

        return obj;

    }

function initFlashCheck(){

  const object = createFlashDetectObject();

  setTimeout(() => {   

 

    const isFlashEnabled = (object.StopPlay !== undefined);

    console.log('isFlashEnabled', isFlashEnabled);

  }, 1000);

}

initFlashCheck();

Best,

Amal

    This topic has been closed for replies.

    1 reply

    jeromiec83223024
    Inspiring
    April 11, 2017

    Our recommendation is to use SWFObject for Flash detection:

    https://github.com/swfobject/swfobject

    That said, things are a little messy at the moment.  As each of the major US browsers pursues their own strategy for deferring the loading of Flash objects (i.e. making Flash Player click-to-play), Flash Player is only visible from JavaScript once the browser (or end-user) chooses to allow it to run.  This means that you'll probably want to take advantage of the ability to supply alternate content for embed/object tags in HTML to provide useful instructions to impacted end-users.

    Since the decision about whether or not Flash content loads at launch is determined by the browser, there's not anything we can do programmatically to smooth that out.  If you're looking for an example of how to do this well, the folks at Zynga do a fantastic job of dealing with this already for Farmville 2 (www.farmville2.com).

    We're continuing to monitor the space, make recommendations to vendors and look for opportunities to improve those new experiences for content developers and end-users, but we're in the middle of that transition now, and the landscape is more fragmented than we'd like at the moment.