문제

im new to javascript and am intersted in creating a small o3d script:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test Game Website</title>
</head>

<body>

<script type="text/javascript" src="o3djs/base.js"></script>
<script type = "text/javascript" id="myscript">

o3djs.require('o3djs.camera');

window.onload = init;

function init(){
 document.write("jkjewfjnwle");
}

</script>

<div align="background">
 <div id="game_container" style="margin: 0px auto; clear: both; background-image: url('./tmp.png'); width: 800px; height:600px; padding: 0px; background-repeat: no-repeat; padding-top: 1px;"></div>
</div>

</body>
</html>

the browser cant seem to find o3djs/base.js in this line

<script type="text/javascript" src="o3djs/base.js"></script>

and gives me an uncaught referenceerror at this line

 o3djs.require('o3djs.camera');

Obviously, because it can't find the o3djs/base.js...

I have installed the o3d pluggin from google and they say that should be IT ive tried on firefox, ie and chrome

thanks

도움이 되었습니까?

해결책

Files that your HTML point to (CSS, JS, links) are searched relative to the document's path.

E.g. if your document's URL is http://localhost/foo/testpage.html, in this case you must put mentioned base.js in http://localhost/foo/o3djs/, etc. So, if your localhost is at C:\Server (assuming you use some Windows-like environment), the file must be called C:\Server\foo\o3djs\base.js.

다른 팁

Also make sure you include all the other files needed by the API, most of them can be found here: http://o3d.googlecode.com/svn/trunk/samples_webgl/o3djs/

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top