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

カラーボックスの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 に答える