Cara Membuat Link Otomatis di Postingan Blog

CB Blogger | November 01, 2015

Cara Membuat Internal Link & Eksternal Link Otomatis di Postingan Blog. Tanpa harus susah-payah secara manual membuat link di artikel. Contohnya, kata blog ini otomatis nge-link ke CB Blogger.

Cara Membuat Link Otomatis di Postingan Blog

KODE SEO SMART LINK
Simpan di atas kode </body>

<script type='text/javascript'>
function smartLink(){
    this.keywdHref = new Object();
    this.add = function(keyword, href){
        if(keyword.substr(0,1) != &quot; &quot;){keyword = &quot; &quot; + keyword;}
        this.keywdHref[keyword] =  href;
    }
    this.createAnchor = function(){
        var objs = document.getElementsByTagName(&quot;div&quot;);
        for(var i=0; i&lt;objs.length; i++){
            var obj = objs[i];
            if(obj.className.indexOf(&quot;post-body&quot;)&gt;-1){
                var content = obj.innerHTML;
                for(var keyword in this.keywdHref){
                    var href = this.keywdHref[keyword];
                    var newstr = content.replace(keyword, &quot;&lt;a href=&#39;&quot;+href+&quot;&#39;&gt;&quot;+keyword+&quot;&lt;/a&gt;&quot;, &quot;gi&quot;);
                    obj.innerHTML = newstr;
                    content = newstr;
                }
            }
        }
    }
    this.startScript = function(){
        var onLoad = window.onload;
        window.onload = function(){
            if(onLoad){onLoad();}
            setTimeout(&quot;f.createAnchor()&quot;, 100);
        }
    }
}
</script>
<script type='text/javascript'>
var f = new smartLink();
f.add(&quot;CB&quot;, &quot;http://www.contohblog.com/&quot;);
f.startScript();
</script>

JIKA ingin menambahkan kata kunci lainnya untuk otomatis link, tambahkan:

f.add(&quot;SEO&quot;, &quot;http://www.contohblog.com/&quot;);
f.add(&quot;Template&quot;, &quot;http://www.contohblog.com/&quot;);
f.add(&quot;Blogger&quot;, &quot;http://www.blogger.com/&quot;);

Previous
« Prev Post

Related Posts

2 komentar on Cara Membuat Link Otomatis di Postingan Blog

  1. apakah aman meletakan kode tersebut diatas Sob,di HTMl blog kita,terus kalau themplate premium, apakah kode tersebut sudah disematkan di dalam HTMl themplatenya, trimaksih

    ReplyDelete

 
Copyright © 2020. New Johny Wuss - All Rights Reserved
Template by CB Blogger & Maskolis