Click here to Skip to main content
13,200,729 members (53,327 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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.

I use
<script type="text/javascript" src=""></script>
but get the same error Error: Object doesn't support this property or method.
Posted 17-Dec-12 18:51pm
Updated 17-Dec-12 19:04pm
Rate this: bad
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.[^]
Manojit Mondal 18-Dec-12 1:17am
Yes I see that but there is no way to do this?
adi007me_syn 18-Dec-12 1:23am
Depends upon what you want to do. Give some more details.
Manojit Mondal 18-Dec-12 1:45am
Is not there any js present to support the 2d functions on IE 7,8?
adi007me_syn 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.
Manojit Mondal 18-Dec-12 4:36am
Its works........:)
adi007me_syn 18-Dec-12 4:45am
Rate this: bad
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"
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
[__i__]Browser Support for HTML5<br />
 <br />
HTML5 is not yet an official standard, and no browsers have full HTML5 support.<br />
 <br />
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-
no browsers have full HTML5 support.

I think you should update your browser.
Manojit Mondal 18-Dec-12 1:53am
Yes but when I create a test page like
<!DOCTYPE html>

<canvas id="myCanvas" width="200" height="100" style="border:1px solid #c3c3c3;">
Your browser does not support the HTML5 canvas tag.


var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");


it does not run on IE 7,8 .
got the same error.
Abhishek Pant 18-Dec-12 2:27am
check my updated solution
Rate this: bad
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

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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.171020.1 | Last Updated 18 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100