Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#JavascriptHTML
Hi,
I have a serious problem in my Jquery + .Net project.
Here I use a html canvas to draw some circles using jquery. Its runs fine in all browsers except IE 7,8,9. When i debug the section of code I see an exception occurs and the message is "object error". My code is
 
<script src='~/js/excanvas.js' type="text/javascript"></script>
 
var canvas = document.getElementById('My_canvas');
var centerX = canvas.width / 2;
var centerY = canvas.height / 2;
var context = canvas.getContext('2d');
 
centerX and centerY shows the right values but when it executes the next then got the error.
 
Please help me to run it in IE family.
ThanksSmile | :)
 
I use
<script type="text/javascript" src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
but get the same error Error: Object doesn't support this property or method.
Posted 17-Dec-12 18:51pm
Edited 17-Dec-12 19:04pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Thank you adi007me_syn,
I check your last link and this is working in IE 7 also.
But I solved it by myself.
There is some problem in my excanvas.js I think.
I download its latest version for IE family also from http://code.google.com/p/canvas-text/source/browse/trunk/excanvas.js
 
And change my code
 
function initCanvas(canvas) {
if (window.G_vmlCanvasManager && window.attachEvent && !window.opera) {
canvas = window.G_vmlCanvasManager.initElement(canvas);
}
return canvas;
}
window.onload = function(){
var canvas = initCanvas(document.getElementById('My_canvas')),
ctx = canvas.getContext('2d');
ctx.strokeStyle = "rgba(255,0,0,1)";
ctx.fillStyle = "rgba(0,0,0,1)";
ctx.lineWidth = 1;
ctx.font = "20pt Verdana, sans-serif";
ctx.translate(60, 60);
ctx.fillText('Horizontal', 0, 0);
 

And it works.
Cheers.Smile | :)
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

HTML 5 is supported only on IE v9 and above.
Check this link to test the features supported by your browser.
http://html5test.com/[^]
  Permalink  
Comments
Manojit Mondal at 18-Dec-12 1:17am
   
Yes I see that but there is no way to do this?
adi007me_syn at 18-Dec-12 1:23am
   
Depends upon what you want to do. Give some more details.
Manojit Mondal at 18-Dec-12 1:45am
   
Is not there any js present to support the 2d functions on IE 7,8?
adi007me_syn at 18-Dec-12 2:39am
   
You can use jquery but its very limited, thats why I asked about the requirement. I am not aware of any script which imitates the Canvas functionality. You can check below link, but I have never tried this. http://code.google.com/p/explorercanvas/
Manojit Mondal at 18-Dec-12 4:36am
   
Its works........:)
adi007me_syn at 18-Dec-12 4:45am
   
Gr88
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

A Developer’s Guide to HTML5 Canvas[^]
HTML5 Canvas[^]
make sure you defined height/width in java script.
also correct this 'My_canvas' to "My_canvas"
also
adi007me_syn :
HTML 5 is supported only on IE v9 and above.
Also I tried your given code and it runs successfully in Internet Explorer version 9.08112.16421 i.e. IE9
Quote:
Browser Support for HTML5

HTML5 is not yet an official standard, and no browsers have full HTML5 support.

But all major browsers (Safari, Chrome, Firefox, Opera, Internet Explorer) continue to add new HTML5 features to their latest versions.

 

and HTML5 & CSS3 Support[^] best describes that-
Quote:
no browsers have full HTML5 support.

 
I think you should update your browser.
  Permalink  
v3
Comments
Manojit Mondal at 18-Dec-12 1:53am
   
Yes but when I create a test page like <!DOCTYPE html> <html> <body> <canvas id="myCanvas" width="200" height="100" style="border:1px solid #c3c3c3;"> Your browser does not support the HTML5 canvas tag. </canvas> <script> var c=document.getElementById("myCanvas"); var ctx=c.getContext("2d"); ctx.fillStyle="#FF0000"; ctx.fillRect(0,0,150,75); </script> </body> </html> it does not run on IE 7,8 . got the same error.
Abhishek Pant at 18-Dec-12 2:27am
   
check my updated solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Shai Vashdi 1,518
1 OriginalGriff 478
2 Manas Bhardwaj 349
3 Tadit Dash 285
4 Damith Weerasinghe 260
0 Sergey Alexandrovich Kryukov 9,575
1 OriginalGriff 5,856
2 Peter Leow 4,405
3 Maciej Los 3,540
4 Abhinav S 3,513


Advertise | Privacy | Mobile
Web02 | 2.8.140415.2 | Last Updated 18 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid