javascriptmodernizryepnope

How to check for FormData using Modernizr and YesNope Javascript


How do I check for FormData object using Modernizr and YepNope?

<script>
yepnope({  
  test : what.to.check,  
  yep  : 'normal.js',  
  nope : 'flashupload.js'  
});      
</script>

Solution

  • I was looking for a Modernizer way to check FormData the other day and couldn't find one.

    However, it's easy to do without Modernizer:

    window.FormData // exists if it exists, undefined if it doesn't!
    

    So:

    yepnope({  
      test : "FormData" in window,
      yep  : 'normal.js',  
      nope : 'flashupload.js'  
    });   
    

    FWIW, MDC compatability for FormData says you'll be targeting:

    ... Opera support is unknown