“不是函数” javascript错误(jquery floatbox插件)
我一直想知道为什么 floatbox 插件无法将 div 容器放在页面的右下角。 http://www.phpletter.com/Demo/Jquery-Floating-Box -插件/ 今天我用firebug检查了我的网站,发现了这个错误:
$("#thediv").floating 不是 功能
在线:$("#thediv").floating({targetX:"right", targetY:"底部"});
这是代码:
<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript" src="/js/jquery.floatingbox.js"></script>
<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(
function(){
jQuery("#thediv").floating({targetX:"right", targetY:"bottom"});
}
);
</script>
浮动函数在插件中是这样创建的:
jQuery.fn.floating = function(options)
{
return jQuery(this).each(
function(i)
{
var nextIndex = 0;
for(var index in funcFloating)
{
nextIndex = parseInt(index);
}
funcFloating[nextIndex + 1] = {};
funcFloating[nextIndex + 1].box = this;
funcFloating[nextIndex + 1].obj = new floatingBox(this, options, (nextIndex + 1));
funcFloating[nextIndex + 1].func = function(){ funcFloating[nextIndex + 1].obj.doFloat(); };
if (document.layers)
{
funcFloating[nextIndex + 1].obj.init();
}else
{
funcFloating[nextIndex + 1].obj.init();
funcFloating[nextIndex + 1].obj.initSecondary();
}
}
);
};
我能做些什么来解决这个问题? 当查看插件示例页面上的源代码时,我发现使用了与我自己的页面相同的代码。
如果这是某种冲突错误,那么第一次使用“$”(在“$(document)”中)不会已经触发错误吗?
I always was wondering why the floatingbox plugin was not able to put a div container at the bottom right of my page.
http://www.phpletter.com/Demo/Jquery-Floating-Box-Plugin/
Today I checked my site with firebug, and found this error:
$("#thediv").floating is not a
functionON LINE: $("#thediv").floating({targetX:"right",
targetY:"bottom"});
Here is the code:
<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript" src="/js/jquery.floatingbox.js"></script>
<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(
function(){
jQuery("#thediv").floating({targetX:"right", targetY:"bottom"});
}
);
</script>
The floating function is created like this in the plugin:
jQuery.fn.floating = function(options)
{
return jQuery(this).each(
function(i)
{
var nextIndex = 0;
for(var index in funcFloating)
{
nextIndex = parseInt(index);
}
funcFloating[nextIndex + 1] = {};
funcFloating[nextIndex + 1].box = this;
funcFloating[nextIndex + 1].obj = new floatingBox(this, options, (nextIndex + 1));
funcFloating[nextIndex + 1].func = function(){ funcFloating[nextIndex + 1].obj.doFloat(); };
if (document.layers)
{
funcFloating[nextIndex + 1].obj.init();
}else
{
funcFloating[nextIndex + 1].obj.init();
funcFloating[nextIndex + 1].obj.initSecondary();
}
}
);
};
What can I do to fix this?
When looking at the source code on the plugin's example page, I see the same code is used as on my own page.
If this was a conflict error of some sorts, wouldn't the first use of "$" (in "$(document)") already trigger an error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
那么,您确定
floating()
函数已在 jQuery 对象原型$.fn
上定义吗?$
对象存在。编辑:根据代码示例,它被包含在正确的顺序中。您有链接以便我们查看问题吗?
Well, are you sure that the
floating()
function has been defined on$.fn
, the jQuery object prototype?$
object exists at the time the plugin tries to extend the prototype.Edit: According to the code sample, it is being included in the right order. Do you have a link so we can see the problem?
这个插件? 如果有,请看一下在该页面的源代码中查看示例。一:
This plugin? If so, take a look at the source of that page for an example. One: