开发者

once again..."$ is not defined" - trying to implement sIFR

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">  
$(doc开发者_JAVA技巧ument).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


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.


Seems like you didn't include any reference to JQuery before that call, that's why '$' is undefined. Try to add this before:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js" type="text/javascript"></script>


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) is a method provided by the jQuery library to run callback 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.


Simply add jQuery to your head before sifr is loaded.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜