<html>
<body>
<script src="raphael.js" type="text/javascript"></script>
<script>// Each of the following examples create a canvas that is 320px wide by 200px high
// Canvas is created at the viewport’s 10,50 coordinate
var paper = Raphael(10, 50, 320, 200);
// Canvas is created at the top left corner of the #notepad element
// (or its top right corner in dir="rtl" elements)
var paper = Raphael(document.getElementById("notepad"), 320, 200);
// Same as above
var paper = Raphael("notepad", 320, 200);
// Image dump
var c = paper.circle(50, 50, 40);
var set = Raphael(["notepad", 320, 200, {
type: "rect",
x: 10,
y: 10,
width: 25,
height: 25,
stroke: "#f00"
}, {
type: "text",
x: 30,
y: 40,
text: "Dump"
}]);
</script>
</body>
我正在测试/学习Raphael,并使用Chrome浏览器在ubuntu的XAMPP中运行此HTML代码。但没有任何东西显示出来。虽然,我有raphael.js文件在html文件的同一文件夹中。
错误是什么?
答案 0 :(得分:4)
我不使用Raphael所以我不知道内部工作原理,但在第一眼看来,我似乎缺少一个id为notepad
的html元素。像一些容纳画布的容器
<div id="notepad">
</div>