0

以下の jsfiddle を使用して、fancybox のタイトルにソーシャル ボタンを追加しています。2つの問題があります

1) jsfiddle では動作しますが、href に "this.href" コードを使用すると、いいね ボタンが表示されません。

2) ツイートの共有ボタンを使用すると、自分の Web サイトのタイトルが共有されますが、jsfiddle ではタイトルと画像の URL が表示されます。代わりに IFRAME のタイトルと URL を表示することはできますか? (jsfiddle でわかるように、私の fancybox のタイプは iframe です)。

JSFIDDLE: http://jsfiddle.net/kmLWf/44/

$.fancybox.update();
    $('.iframe').fancybox({         

    beforeShow: function () {if (this.title) {
            // New line
            this.title += '<br />';

            // Add tweet button
            this.title += '<a href="https://twitter.com/share" class="twitter-share-button" data-count="none" data-url="' + this.href + '">Tweet</a> ';

            // Add FaceBook like button
            this.title += '<iframe src="//www.facebook.com/plugins/like.php?href=' + this.href + '&amp;layout=button_count&amp;show_faces=true&amp;width=500&amp;action=like&amp;font&amp;colorscheme=light&amp;height=23" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:110px; height:23px;" allowTransparency="true"></iframe>';}},
    afterShow: function() {
        // Render tweet button
        twttr.widgets.load();
    },
    href:this.href,
    padding:0,
    type:'iframe',
    scrolling : "no",
    prevEffect      : 'fade',
    nextEffect      : 'fade',
    preload:true,
    autoSize : false, 
    autoCenter: true, 
    fitToView : false, 
    loop: false,
    helpers : {
        overlay : {
        css : {
            'background' : 'rgba(0, 0, 0, 0.7)',
            'overflow-y': 'hidden'
                },
            }
        }
    });
4

1 に答える 1

0

画像の href に絶対 URL を追加すると、問題が修正されました。

于 2013-08-27T14:23:37.710 に答える