Cara Memasang Tombol like Facebook, Twitter Tweet, Google+ & Share di Blog.

Posted by

tombol share di blog


Ada banyak cara memasang widget share di blog. Untuk tutorial kali ini, saya akan membagikan sebuah trik mudah memasang Tombol like facebook, twitter tweet, google+ & share di blog. Tombol share ini sendiri berfungsi untuk menyebarluaskan artikel kita. Semakin blog kita dipromosi lewat tombol share ini maka semakin popular juga artikel blog kita. Langsung saja ini dia 

- login ke blog anda
- pilih rancangan --> tambah elemen --> pilih HTML/Javascript
- Lalu copy kode berikut ke dalam nya.


<!-- AddThis Button BEGIN -->
<script type="text/javascript" src="http://s7.addthis.com/js/300/addthis_widget.js"></script>

<script type='text/javascript'>

document.doAT = function(cl)

{

        var myclass = new RegExp('hentry');
        var myTitleContainer = new RegExp('post-title');
        var myPostContent = new RegExp('post-footer');
        var elem = this.getElementsByTagName('div');
        for (var i = 0; i < elem.length; i++)
        {
            var classes = elem[i].className;
            if (myclass.test(classes))
            {
                var container = elem[i];
                for (var b = 0; b < container.childNodes.length; b++)
                {
                    var item = container.childNodes[b].className;
                    if (myTitleContainer.test(item))
                    {
                        var link = container.childNodes[b].getElementsByTagName('a');
                        if (typeof(link[0]) != 'undefined')
                        {
                            var url = link[0].href;
                            var title = link[0].innerHTML;
                        }
                        else
                        {
                            var url = document.url;
                            var title =  container.childNodes[b].innerHTML;
                        }
                        if (typeof(url) == 'undefined'|| url == 'undefined' ){
                            url = window.location.href;
                        }
                    var singleq = new RegExp("'", 'g');
                    var doubleq = new RegExp('"', 'g');                                                                                                                                                                                                                         
                    title = title.replace(singleq, '&#39;', 'gi');
                    title = title.replace(doubleq, '&#34;', 'gi');
                  
                    }
                    if (myPostContent.test(item))
                    {
                        var footer = container.childNodes[b];
                    }
                }
                var n = document.createElement('div');
                var at = "<div class='addthis_toolbox addthis_default_style ' addthis:title='"+title+"' addthis:url='"+encodeURI(url)+"'   > <a class='addthis_button_facebook_like' fb:like:layout='button_count'></a> <a class='addthis_button_tweet'></a> <a class='addthis_button_google_plusone' g:plusone:size='medium'></a> <a class='addthis_counter addthis_pill_style'></a> </div> ";
                n.innerHTML = at;
                container.insertBefore(n , footer);
            }
        }
    return true;
};



document.doAT('hentry');

</script>

<!-- AddThis Button END -->



- jangan lupa klik Save.

Hasilnya akan seperti gambar di bawah ini

memasang tombol share di blog


Blog, Updated at: 11:48 PM

0 comments:

Post a Comment