1

私はJqueryを初めて使用し、Cookieとオンロード機能を使用してライトボックスを開く例をいくつか見つけました。私はfancyboxで動作するcookieの例を使用していますが、すべてのサイトでprettyPhotoを使用しており、実際にはfancyboxに変更したくありません。私はこれを機能させるために十数の異なる方法を試しましたが、運がありません。これが私のコードです。どんな助けや提案も素晴らしいでしょう。

$(document).ready(function(){

// !!! SEE THIS PLEASE !!!
// delete this line to make the modal box load only ONCE
// if you let it set to 'false' it will show every time .. set it to 'true' and it will never show
$.cookie("modal", 'false')

/**
  *  MODAL BOX
  */
// if the requested cookie does not have the value I am looking for show the modal box
if($.cookie("modal") != 'true')
{
    alert("sometext");

var where = "http://images.motortrend.com/photo_gallery/112_0611_39z+2006_bugatti_veyron+interior.jpg"; var title = ""; var comment = "";

関数showLbox(){$ .prettyPhoto.open(where、title、comment); }//ページの読み込み時にモーダルボックスを表示します//fancyboxサイトで見つけることができるオプションに関する詳細情報

    // in the message is a link with the id "modal_close"
    // when you click on that link the modal will close and the cookie is set to "true"
    // path "/" means it's active for the entire root site.. if you set it to "/admin" will be active on the "admin" folder
    // expires in 7 days
    // "modal" is the name i gave the cookie.. you can name it anything you want
    $('#modal_close').live('click', function(e) {
        e.preventDefault();
        $.cookie("modal", "true", { path: '/', expires: 7 });


    });
}

});

4

1 に答える 1

3

ページの読み込みが完了したら、S.prettyPhoto.open API 関数を呼び出す必要があります。$(document).ready(function() 関数の下に置きます。

$(document).ready(function(){
            $(".gallery:first a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'fast',slideshow:10000});
            $(".gallery:gt(0) a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'fast',slideshow:10000});

            $("#custom_content a[rel^='prettyPhoto']:first").prettyPhoto({
                custom_markup: '<div id="map_canvas" style="width:260px; height:265px"></div>',
                changepicturecallback: function(){ initialize(); }
            });

            $("#custom_content a[rel^='prettyPhoto']:last").prettyPhoto({
                custom_markup: '<div id="bsap_1237859" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6" style="height:260px"></div><div id="bsap_1251710" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6"></div>',
                //changepicturecallback: function(){ _bsap.exec(); }

            });
            $.prettyPhoto.open('FMWM5.swf?width=544 &amp;height=399', '', 'Click anywhere to skip intro...');
            setTimeout("$.prettyPhoto.close()", 8000);

        });

changepicturecallback で「_bsap が定義されていません」というエラー (firebug で見られる) が表示されたので、コメントアウトしました。

テストに使用したスクラップ ページは次のとおりです: http://www.fortmitchellwalmart.com/prettyPhotoTest/index.html

Cookie ブール値で無効にする方法がわかりません。JavaScript とフラッシュの初心者ですが、これが役立つことを願っています。

于 2011-03-30T23:45:21.683 に答える