0

如果存在查询字符串,如何让我的颜色框自动显示。到目前为止,我有以下内容:

$(document).ready(function ()
{
    //if this is coming from continental
    if (document.location.href.indexOf("redirect=cfs") != -1)
    {
        //create box
        var $notice = $("<div>hello World</div>").appendTo($("body"));
        console.log($notice.text());
        $notice.colorbox({ inline: true, width: "965px" });
    }
});

但这无济于事,因为您似乎需要以某种方式触发颜色框来显示某些内容?

编辑: 我刚刚意识到您可以使用$.colorbox,但是如何将我的内容放入其中?

问候, 雅克

4

2 回答 2

1

只需使用 colorbox 的 html 属性:

$(document).ready(function (){
    if (document.location.href.indexOf("redirect=cfs") != -1)
    {
        var $notice = $("<div>hello World</div>");
        $notice.colorbox({ html: $notice, width: "965px" });
    }
});
于 2012-07-25T15:51:32.217 回答
0

以下代码为我完成了它:

$(document).ready(function ()
{
    //if this is coming from continental
    if (document.location.href.indexOf("redirect=cfs") != -1)
    {
        //create box
        var $notice = $("<div id='partnerMove'>test</div>").appendTo($("body"));
        console.log($notice.text());
        **$.colorbox({ href: '#partnerMove', inline: true, width: "600px" });**
    }
});

因此,您可以即时创建 HTML 元素,然后使用$.colorboxcolorbox 的href设置引用新元素。

于 2012-07-25T12:33:44.130 回答