Rajneesh
Rajneesh

Reputation: 2291

Unable to use Raphaël library

I am having a problem in using Raphaël library. Im getting following error

'R._g.doc.body' is null or not an object

i just used following code

<html>
<head>
<script src="raphael.js"></script>
<script>
// Creates canvas 320 × 200 at 10, 50
var paper = Raphael(10, 50, 320, 200);

// Creates circle at x = 50, y = 40, with radius 10
var circle = paper.circle(50, 40, 10);
// Sets the fill attribute of the circle to red (#f00)
circle.attr("fill", "#f00");

// Sets the stroke attribute of the circle to white
circle.attr("stroke", "#fff");

</script>
</head>
</html>

I used IE8 for this

Upvotes: 1

Views: 282

Answers (2)

Mr. Alien
Mr. Alien

Reputation: 157314

You are not using <body></body>n and put your script in the body rather than head

try this

<html>
<head>
<script src="raphael.js"></script>
</head>
<body>
  <script>
// Creates canvas 320 × 200 at 10, 50
var paper = Raphael(10, 50, 320, 200);

// Creates circle at x = 50, y = 40, with radius 10
var circle = paper.circle(50, 40, 10);
// Sets the fill attribute of the circle to red (#f00)
circle.attr("fill", "#f00");

// Sets the stroke attribute of the circle to white
circle.attr("stroke", "#fff");

</script>
</body>
</html>

Upvotes: 1

Christofer Eliasson
Christofer Eliasson

Reputation: 33865

Not sure, but given your code and what the error message says, I'd say you need to have a <body></body> tag in your document.

Not sure if that is an IE8 thing. I put together your example in a fiddle and for me, in Chrome 22, it works without the body tag as well.

Upvotes: 1

Related Questions