我想跟随在http://dojotoolkit.org/book/dojo-book-0-9/part-3-programmatic-dijit-and-dojo/modules-and-namespaces/creating-your-own-modul无法加载定制的Dojo模块
我有道场的本地部署自定义模块教程在http://localhost:8081/dojo-1.3.2/dojo/dojo.js 对于我创建了以下javascript文件在http://localhost:8081/dojo-1.3.2/explosive/space/Modulator.js我的自定义模块:
dojo.provide("explosive.space.Modulator");
dojo.declare("explosive.space.Modulator",null,{
bob:1
});
在我的HTML页面中我有以下几点:
<script type="text/javascript" src="http://localhost:8081/dojo-1.3.2/dojo/dojo.js"></script>
<script type="text/javascript">
dojo.require("explosive.space.Modulator");
</script>
而且当我在Firefox中拉起我的网站时,出现错误:
Error: Could not load 'explosive.space.Modulator'; last tried '../explosive/space/Modulator.js'
对我在做什么有什么错误的想法?
编辑:经过更多的测试后,它出现的代码适用于IE8和IE8兼容模式,但不适用于Firefox,Chrome或Opera。
编辑2:我的HTML文件是在不同的域名,但我不认为这应该有所作为。在阅读了Seth的评论(感谢Seth!)之后,我尝试了两种方法。
我有两个tomcat实例,一个在端口8080上,另一个在端口8081上。我已经在两个实例中放置了index.htm,并启动它们。
http://localhost:8081/test/index.htm适用于FF和IE。 http://localhost:8080/test/index.htm在FF中无法正常工作,但在IE中可以正常工作。
显示XmlHTTPRequests显示FF正在打电话给“GET http://localhost:8081/dojo-1.3.2/explosive/space/Modulator.js”,由于某种原因,它将返回一个空响应。
这是我的index.htm的完整代码,如果有任何帮助的话。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<title>Create Map</title>
<script type="text/javascript" src="http://localhost:8081/dojo-1.3.2/dojo/dojo.js"></script>
<script type="text/javascript">
dojo.require("explosive.space.Modulator");
function init(){
var eludiumFuel36 = new explosive.space.Modulator();
alert(eludiumFuel36.bob);
}
dojo.addOnLoad(init);
</script>
</head>
<body class="tundra">
<h1>Hello World!</h1>
</body>
</html>
我在回复中添加了一些内容到我的帖子中。顺便说一句,谢谢。 – Phil 2009-09-17 17:31:59
好的,更新我的答案以反映新的信息。 – seth 2009-09-17 19:33:23