Webshim polyfill canvas will not work in IE7 mode

I am having trouble working with the webshims canvas polyfill plugin.

I get the following error in IE9 using IE7 mode:

  SCRIPT438: Object doesn't support property or method 'fillRect'
  problem.html, line 21 character 7

when I try to run this code:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
    <title>DealingTree</title>
    <meta http-equiv="Content-type" content="text/html;charset=utf-8"/>
    <script type="text/javascript" src="/js/modernizr.js"> </script>
    <script type="text/javascript" src="/js/jquery.js"> </script>
    <script type="text/javascript" src="/js/sssl.js"> </script>
    <script type="text/javascript" src="/js/webshims/js-webshim/minified/polyfiller.js"> </script>
  </head>
  <body>
    <canvas id="savings" height="350" width="700"> </canvas>
    <script type="text/javascript">
      //<![CDATA[
      window.FlashCanvasOptions = { disableContextMenu: true };
      $.webshims.setOptions( 'canvas', { type: 'flashpro' } );
      $.webshims.polyfill('canvas');
      var canvas = $('#savings');
      var context = canvas.getContext('2d');
      context.fillStyle='#F00';
      context.fillRect(0,0,700,350);
      //]>
    </script>
  </body>
</html>

The problem occurs if I use default (excanvas) or flashpro.

UPDATE: It seems to me that getContext () returns a jQuery object instead of context.

Help me please?

+3
source share
1 answer

I received the following explanation from the plugin author, Alexander Farkas, by email:

. Webshims script. . , .

domready, :

window.FlashCanvasOptions = { disableContextMenu: true };
$.webshims.setOptions( 'canvas', { type: 'flashpro' } );
$.webshims.polyfill('canvas');
$(function(){
     var canvas = $('#savings');
     var context = canvas.getContext('2d');
     context.fillStyle='#F00';
     context.fillRect(0,0,700,350);
});

@ http://afarkas.github.com/webshim/demos/index.html#polyfill-ready

+1

All Articles