4
看来我已经错误地安装了Scriptaculous,但我无法弄清楚什么是错的。下面是一个示例来显示问题:使用Scriptaculous时没有定义效果
<html>
<body>
<script src="js/prototype.js" type="text/javascript"></script>
<script src="js/scriptaculous.js" type="text/javascript"></script>
<p id="hello">Hello, World!</p>
<a href="javascript:void(0)" onclick="Effect.Shrink('hello');">Shrink effect</a>
<a href="javascript:void(0)" onclick="$('hello').shrink();">Shrink method</a>
</body>
</html>
当我单击“收缩效果”链接时,出现Javascript错误,“效果未定义”。当我点击“收缩方法”链接时,我得到一个不同的错误,“$(”hello“)。shrink不是函数。”
的问题消失,如果我明确地链接到影响脚本:
<html>
<body>
<script src="js/prototype.js" type="text/javascript"></script>
<script src="js/scriptaculous.js" type="text/javascript"></script>
<script src="js/effects.js" type="text/javascript"></script> <!-- Added -->
<p id="hello">Hello, World!</p>
<a href="javascript:void(0)" onclick="Effect.Shrink('hello');">Shrink effect</a>
<a href="javascript:void(0)" onclick="$('hello').shrink();">Shrink method</a>
</body>
</html>
此解决方案是可以接受的,但不能加载Scriptaculous的所有辅助脚本自动?它似乎是installation instructions说它应该。
我的html文件和js文件夹不在web服务器的根文件夹中,它们都在应用程序文件夹下。我在Firefox 3.5.7和Internet Explorer 8.0中看到了相同的行为。
现在我再次阅读说明,我看到“这是通过链接到文档的头部*脚本来完成的。” – 2010-02-05 18:21:57