jQuery Colorbox Iframe和选择器

jQuery Colorbox Iframe和选择器,jquery,iframe,colorbox,Jquery,Iframe,Colorbox,我有这个: $("a.money").colorbox({href:$("a.money").attr("href")+" div#content"}); 这将打开覆盖,但仅打开#内容选择器中的内容。如果我添加iframe:true,这将不再有效。有没有办法让它与iframe一起工作 编辑: 我能让它工作的最接近的方法是这样做: $("a.money").colorbox({iframe:true, width:700, height:425, onComplete: function

我有这个:

$("a.money").colorbox({href:$("a.money").attr("href")+" div#content"});
这将打开覆盖,但仅打开#内容选择器中的内容。如果我添加iframe:true,这将不再有效。有没有办法让它与iframe一起工作

编辑: 我能让它工作的最接近的方法是这样做:

$("a.money").colorbox({iframe:true, width:700, height:425,
    onComplete: function() {
        alert('test');
        $test = $("#cboxLoadedContent iframe").contents().find("#content").html();
        $("#cboxLoadedContent iframe").contents().find("#container").html($test);
    } 
});
虽然在没有警报的情况下,它似乎不起作用,但我对此进行了研究,认为我需要使用.live(),这让我尝试了以下方法:

$('a.money').live('click', function() { 
    url = this.href; // this is the url of the element event is triggered from
    $.fn.colorbox({href: url, iframe:true,width:700, height:425,
        onComplete: function() {
            $test = $("#cboxLoadedContent iframe").contents().find("#content").html();
            $("#cboxLoadedContent iframe").contents().find("#container").html($test);
        } 
    });
    return false;
});
没有工作,我仍然需要添加一个警报使其工作

万一你想知道我想做什么。网页加载到iframe中,所有元素都在#容器中,因此包括#标题和#边栏,但我只想显示iframe中的#内容。然而,这让我意识到了另一个问题。假设我在没有警报的情况下让它工作,它将只在初始页面工作。例如,如果我在iframe中加载了一个表单,在提交表单后,我将再次看到整个布局,而不仅仅是内容部分。在进一步导航后是否可以继续只显示页面的#内容部分?

这应该可以

  $("a.money").colorbox({ href:"#content", inline: true, iframe: true });
  <div id='content'>Any content here</div>
  <a class='money' href="#">question</a>
$(“a.money”).colorbox({href:#content”,inline:true,iframe:true});
这里有什么内容吗
这应该行得通

  $("a.money").colorbox({ href:"#content", inline: true, iframe: true });
  <div id='content'>Any content here</div>
  <a class='money' href="#">question</a>
$(“a.money”).colorbox({href:#content”,inline:true,iframe:true});
这里有什么内容吗

根据这些线程中的代码,我找到了一个替代解决方案:

http://groups.google.com/group/colorbox/browse_thread/thread/8a0deec97202e27c/2e7524b87931a89e


它不使用iframe,但它或多或少正是我想要的。

根据这些线程中的代码,我找到了一个替代解决方案:

http://groups.google.com/group/colorbox/browse_thread/thread/8a0deec97202e27c/2e7524b87931a89e


它不使用iframe,但它或多或少正是我想要的。

没有警报,您的初始代码无法工作的原因是,除了需要“onComplete”函数外,您还需要iframe上的加载事件。该警报为iframe提供了加载时间,从而使代码正确呈现

所以,它应该看起来像:

$("a.money").colorbox({iframe:true, width:700, height:425,
    onComplete: function() {
        $("#cboxLoadedContent iframe").load(function(){
              $test = $(this).contents().find("#content").html();
              $(this).contents().find("#container").html($test);
    });
    } 
});

初始代码在没有警报的情况下无法工作的原因是,除了需要“onComplete”函数外,您还需要iframe上的加载事件。该警报为iframe提供了加载时间,从而使代码正确呈现

所以,它应该看起来像:

$("a.money").colorbox({iframe:true, width:700, height:425,
    onComplete: function() {
        $("#cboxLoadedContent iframe").load(function(){
              $test = $(this).contents().find("#content").html();
              $(this).contents().find("#container").html($test);
    });
    } 
});

抱歉,如果我不太清楚,我实际上需要iframe中的内容,该iframe正在从另一个页面加载内容。所以我需要这样的东西:
$(“a.money”).colorbox({href:$(“a.money”).attr(“href”)+“div#content”,iframe:true,宽度:600,高度:400})
(但这当然不起作用)尝试过,但它不起作用,因为它不是真正的内联内容。很抱歉,如果我不太清楚,我实际上需要iframe中的内容,该iframe正在从另一个页面加载内容。所以我需要这样的东西:
$(“a.money”).colorbox({href:$(“a.money”).attr(“href”)+“div#content”,iframe:true,宽度:600,高度:400})
(但这当然不起作用)尝试过,但不起作用,因为它不是真正的内联content.FYI-对于从谷歌搜索到这里的任何人来说,上面的“groups.Google.com”链接是断开的。FYI-对于从谷歌搜索到这里的任何人来说,上面的“groups.Google.com”链接是断开的。