1

私は自分のウェブサイトに Fancybox 画像ギャラリーを設定し、各画像ポップアップ ボックスにソーシャル共有を統合しました。私が抱えている問題は、誰かがツイートしようとしたときに、ウェブサイトの URL が事前入力された Twitter メッセージに添付されていないことです。

ソーシャルボタンをFancyboxと統合する方法に関するこのJSFiddleチュートリアルに従ったため、何が間違っているのかわかりませんが、コードは私のものとほぼ同じようです...

ソーシャル ボタンの JS は次のとおりです。

$('.fancybox-buttons')
    .attr('rel', 'gallery')
    .fancybox({
        openEffect  : 'none',
        closeEffect : 'none',

        prevEffect : 'none',
        nextEffect : 'none',


    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-text="Amazing work by artist Tegan Whitesel!" 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>';

            // Add Pinterest "Pin It" button
            this.title += '<a href="http://pinterest.com/pin/create/button/?url=http://www.teganwhitesel.com/#painting&media=http%3A%2F%2Fwww.teganwhitesel.com%2Fpainting%2Fbeginnings-3_b.jpg&description=Tegan%20Whitesel%20-%20Beginnings%20III" class="pin-it-button" count-layout="none"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /></a>';


        }
    },
    afterShow: function () {
        // Render tweet button
        twttr.widgets.load();
    },
    helpers: {
        title: {
            type: 'inside'
        }, //<-- add a comma to separate the following option
        buttons: {} //<-- add this for buttons
    },
    closeBtn: true, // you will use the buttons now
    arrows: true
});

index.html <header>そして、これが私のサイトの私のセクションにある追加のスクリプトタグです:

<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="http://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
4

0 に答える 0