我试图用philogl库的东西,当我写,身体的onload =“”找不到功能
<!DOCTYPE html>
<html>
<head>
<title>PGL2</title>
<script type="text/javascript" src="PhiloGL.js"></script>
<script type="text/javascript">
function webGLStart(){
alert('I m alive');
}
</script>
</head>
<body onload="webGLStart();">
<canvas id="c" style="width:500px; height:500px;"></canvas>
</body>
</html>
一切工作正常,但如果我写它像一些philogl,
<!DOCTYPE html>
<html>
<head>
<title>PGL2</title>
<script type="text/javascript" src="PhiloGL.js"></script>
<script type="text/javascript">
function webGLStart(){
var triangle = new PhiloGL.O3D.Model({
vertices: [[0,1,0],[-1,-1,0],[1,-1,0]],
colors: [[1,0,0,1],[0,1,0,1],[0,0,1,1]]
});
var square = new PhiloGL.O3D.Model({
vertices: [[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0]],
colors: [[0.5,0.5,1,1],[0.5,0.5,1,1]],[0.5,0.5,1,1]
});
}
</script>
</head>
<body onload="webGLStart();">
<canvas id="c" style="width:500px; height:500px;"></canvas>
</body>
</html>
铬和Firefox给我一个错误,说webGLStart()没有定义。 我的代码有什么问题?
旁边[Pointy的回答](http://stackoverflow.com/questions/5117536/body-onload-cannot-find-function/5117571#5117571)我推荐[Firebug](http://getfirebug.com/) (Firefox的附加组件),它显示了许多关于JavaScript的内容,并帮助您找到混乱的东西。 – Albireo 2011-02-25 13:07:37
不好意思,但主要的问题是我现在不得不使用chrome,因为现在firefox缺乏对webGL的支持,甚至v4b11在每个webgl演示的网站上都会给我提供错误,如果有任何好的独立应用程序... – gkaykck 2011-02-25 13:50:02