再次...“$ 未定义” - 尝试实施 sIFR
我的文件开头看起来像这样:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My title</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script src="js/update.js" type="text/javascript"></script>
<!-- sifr -->
<link href="sifr207/sIFR-screen.css" rel="stylesheet" type="text/css" media="screen" />
<script src="sifr207/sifr.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function()
{
if(typeof sIFR == "function")
{
sIFR.replaceElement("sifr", named({sFlashSrc: "sIFR-2.0.7/corporateacon-reg.swf", sColor: "#FF0000" , sWmode: "transparent"}));
};
});
</script>
<!-- -->
</head>
我真的不明白为什么找不到 '$(document).ready(function()' ,因为我在调用之前实现了 sifr.js 。
有什么建议吗? 我会很感激它,真的!
喊, 监督
my file beginning looks like this:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My title</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script src="js/update.js" type="text/javascript"></script>
<!-- sifr -->
<link href="sifr207/sIFR-screen.css" rel="stylesheet" type="text/css" media="screen" />
<script src="sifr207/sifr.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function()
{
if(typeof sIFR == "function")
{
sIFR.replaceElement("sifr", named({sFlashSrc: "sIFR-2.0.7/corporateacon-reg.swf", sColor: "#FF0000" , sWmode: "transparent"}));
};
});
</script>
<!-- -->
</head>
I really do not understand why the '$(document).ready(function()' is not found, because I implement sifr.js BEFORE that call.
Any suggestions?
I would appriciate it, really!
shoutz,
supervision
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您的文件中没有包含 jQuery.js!
由于 SIFR 是一个 jQuery 插件,因此您必须在
sifr.js
之前加载基础库。尝试添加
you do not have jQuery.js included in your file!
Since SIFR is a jQuery plugin, you have to load the base library before
sifr.js
.Try adding
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript></script>
at the beginning of your script.似乎您在调用之前没有包含任何对 JQuery 的引用,这就是 '$' 未定义的原因。尝试在之前添加此内容:
Seems like you didn't include any reference to JQuery before that call, that's why '$' is undefined. Try to add this before:
因为 sIFR 没有实现
$
函数。您可能打算使用 Prototype.js、jQuery 或其他一些使用该错误命名变量的库。Because sIFR doesn't implement a
$
function. You probably mean to use Prototype.js, jQuery, or some other library that uses that badly named variable.$(document).ready(callback)
是 jQuery 库提供的方法文档解析完成后运行callback
。您的文件中似乎没有引用 jQuery 的脚本,因此此方法不可用。$(document).ready(callback)
is a method provided by the jQuery library to runcallback
when the document parsing has completed. It looks like you don't have a script referencing jQuery in your file, so this method is not available.只需在加载 sifr 之前将 jQuery 添加到您的 head 即可。
Simply add jQuery to your head before sifr is loaded.