【问题标题】:o3d javascript uncaught reference erroro3d javascript未捕获的引用错误
【发布时间】:2010-03-31 13:23:17
【问题描述】:

我是 javascript 新手,有兴趣创建一个小型 o3d 脚本:

<!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>

浏览器似乎在这一行找不到 o3djs/base.js

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

并在这一行给我一个未捕获的参考错误

 o3djs.require('o3djs.camera');

很明显,因为找不到o3djs/base.js...

我已经从 google 安装了 o3d 插件,他们说应该是 IT 我试过火狐,ie和chrome

谢谢

【问题讨论】:

  • 你把那个 javascript 源代码(“base.js”)放在哪里了?您的网页是从哪里提供的?
  • 我现在只是尝试在本地运行该页面。就是这样,o3d 的网站告诉我要做的就是安装插件,我很高兴。

标签: javascript o3d referenceerror


【解决方案1】:

您的 HTML 指向的文件(CSS、JS、链接)相对于文档的路径进行搜索。

例如如果您的文档的 URL 是 http://localhost/foo/testpage.html,在这种情况下,您必须在 http://localhost/foo/o3djs/ 中添加提到的 base.js,等等。因此,如果您的本地主机位于 C:\Server(假设您使用一些类似 Windows 的环境),则该文件必须调用 C:\Server\foo\o3djs\base.js。

【讨论】:

  • 太糟糕了,谷歌没有提到我必须下载一个 zip,甚至没有提到在哪里下载它。我必须从样品中得到它。谢谢
【解决方案2】:

还要确保包含 API 所需的所有其他文件,其中大部分都可以在这里找到:http://o3d.googlecode.com/svn/trunk/samples_webgl/o3djs/

【讨论】:

    猜你喜欢
    • 2014-10-11
    • 2012-12-09
    • 2013-04-10
    • 1970-01-01
    • 2021-09-19
    • 1970-01-01
    • 2013-04-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多