Friday, August 26, 2016
Cara Membuat Link Otomatis di Postingan Blog
Cara Membuat Link Otomatis di Postingan Blog
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.
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) != " "){keyword = " " + keyword;}
this.keywdHref[keyword] = href;
}
this.createAnchor = function(){
var objs = document.getElementsByTagName("div");
for(var i=0; i<objs.length; i++){
var obj = objs[i];
if(obj.className.indexOf("post-body")>-1){
var content = obj.innerHTML;
for(var keyword in this.keywdHref){
var href = this.keywdHref[keyword];
var newstr = content.replace(keyword, "<a href='"+href+"'>"+keyword+"</a>", "gi");
obj.innerHTML = newstr;
content = newstr;
}
}
}
}
this.startScript = function(){
var onLoad = window.onload;
window.onload = function(){
if(onLoad){onLoad();}
setTimeout("f.createAnchor()", 100);
}
}
}
</script>
<script type=text/javascript>
var f = new smartLink();
f.add("CB", "http://www.contohblog.com/");
f.startScript();
</script>
JIKA ingin menambahkan kata kunci lainnya untuk otomatis link, tambahkan:
f.add("SEO", "http://www.contohblog.com/");
f.add("Template", "http://www.contohblog.com/");
f.add("Blogger", "http://www.blogger.com/");
Available link for download