2011-12-30 32 views
0

私はexcanvasを使用してIEで作業するためのキャンバスを取得しようとしています。 しかし、どこにも現れていないようです。Excanvas:ページに表示されない

以下のコードは、IE以外のすべてのブラウザで機能します。

私はexcanvasのプロジェクトページの提案を参考にしてみました。

助けていただけたら幸いです!身体の「オンロード」に「負荷」メソッドを呼び出して、また...

<html> 
    <head> 
     <script type="text/javascript" src="jquery.js"></script> 
     <script type="text/javascript" src="excanvas.compiled.js"></script> 
    </head> 
    <body id="body"> 


<script type="text/javascript"> 

    load(); 

    function load(){ 

     var canvas = document.createElement("canvas"); 

     if(typeof G_vmlCanvasManager !== "undefined") 
      G_vmlCanvasManager.initElement(canvas); 

     var ctx = canvas.getContext("2d"); 
     ctx.fillStyle = "#FF0000"; 
       ctx.beginPath(); 
       ctx.arc(50,50,12,0,Math.PI*2,true); 
       ctx.closePath(); 
       ctx.fill(); 

     document.getElementById("body").appendChild(canvas); 
    } 




</script> 
    </body> 
</html> 
+0

あなたはhttp://stackoverflow.com/questions/941170/does-anyone-couldでIE8、Quirksモードの言及を使用している場合-make-excanvas-work-in-ie-8-with-jqueryは役に立ちます。 –

答えて

0

はなぜ私に聞かないでください、どうやら静的なキャンバスを作成し、それを描画した後、動的に作成されたものは、作業を開始します - それを直接行うのではなく、重要であるように思えます(再び、それが私の理解を超えている理由です)。以下

溶液(IE6)私のためにうまく働いた:

<html> 
    <head> 
     <script type="text/javascript" src="jquery.js"></script> 
     <script type="text/javascript" src="excanvas.compiled.js"></script> 
    </head> 
    <body onload="load()" id="body"> 
     <canvas id="static" style="display:none"></canvas> 
     <script type="text/javascript"> 
      function load(){ 
       // Static 
       var canvas = document.getElementById("static"); 
       var ctx = canvas.getContext("2d"); 
       ctx.fillStyle = "#FF0000"; 
         ctx.beginPath(); 
         ctx.arc(50,50,12,0,Math.PI*2,true); 
         ctx.closePath(); 
         ctx.fill(); 
       // Dynamic 
       var canvas = document.createElement("canvas"); 

       if(typeof G_vmlCanvasManager !== "undefined") 
        G_vmlCanvasManager.initElement(canvas); 

       var ctx = canvas.getContext("2d"); 
       ctx.fillStyle = "#FF0000"; 
         ctx.beginPath(); 
         ctx.arc(50,50,12,0,Math.PI*2,true); 
         ctx.closePath(); 
         ctx.fill(); 

       document.getElementById("body").appendChild(canvas); 
      } 
     </script> 
    </body> 
</html> 
+0

あなたのアドバイスがうまくいった! body onloadを待つだけでなく、G_vmlCanvasManagerで初期化する前に動的に作成されたキャンバス要素を追加する必要がありました。 – KDV

関連する問題