2010-12-11 6 views
1
<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 브라우저를 사용하여 XAMPP에서이 HTML 코드를 실행하고 있습니다. 그러나 아무것도 표시되지 않습니다. 하지만 html 파일의 같은 폴더에 raphael.js 파일이 있습니다.Raphael.js를 사용하는 자바 스크립트 코드의 버그는 무엇입니까?

버그 란 무엇입니까?

답변

4

라파엘을 사용하지 않기 때문에 내부 동작을 알지 못하지만 첫 번째 모습에서는 id가 notepad 인 html 요소가 누락 된 것으로 보입니다. 캔버스를 잡을 수있는 컨테이너와 마찬가지로

<div id="notepad"> 
</div> 
+1

+1 작동합니다 (하지만 ** 자바 스크립트 코드 앞에 ** 삽입해야합니다). –

+0

또는 window.onload에서 자바 스크립트 코드를 실행할 수 있습니다. – skajfes

관련 문제