“不是函数” javascript错误(jquery floatbox插件)

发布于 2024-10-06 01:34:23 字数 1774 浏览 5 评论 0原文

我一直想知道为什么 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
function

ON 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

自找没趣 2024-10-13 01:34:23

那么,您确定 floating() 函数已在 jQuery 对象原型 $.fn 上定义吗?

  1. 确保您已正确包含 floatbox js 文件,
  2. 确保它位于 jquery include 之后,以便在插件尝试扩展原型时 $ 对象存在。

编辑:根据代码示例,它被包含在正确的顺序中。您有链接以便我们查看问题吗?

Well, are you sure that the floating() function has been defined on $.fn, the jQuery object prototype?

  1. Make sure that you've properly included the floatingbox js file
  2. Make sure it's after the jquery include so the $ 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?

别把无礼当个性 2024-10-13 01:34:23

这个插件? 如果有,请看一下在该页面的源代码中查看示例。一:

$('#moving_box1').floatingBox({
    scale : 0.3,
    blur : true,
    isText : false,
    xOffset : 235,
    yOffset: 185,
});

This plugin? If so, take a look at the source of that page for an example. One:

$('#moving_box1').floatingBox({
    scale : 0.3,
    blur : true,
    isText : false,
    xOffset : 235,
    yOffset: 185,
});

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文