How to add auto highlight SearchTerms/auto key word links for blogger/auto key words with links for blogspot
This tourial will show you how to add auto keyword - links for blogger (it will create automatic links for key words in your blog's posts)
This tourial will show you how to add auto keyword - links for blogger (it will create automatic links for key words in your blog's posts)
1. Click "edit HTML"
2. Choose one of the following codes and paste it before </head>
The first code: All the links will open in the current window
The first code: All the links will open in the current window
<script type='text/javascript'>
//<![CDATA[
function doHighlight(a,c,f){for(var d="",b=-1,g=c.toLowerCase(),e=a.toLowerCase();0<a.length;)b=e.indexOf(g,b+1),0>b?(d+=a,a=""):a.lastIndexOf(">",b)>=a.lastIndexOf("<",b)&&e.lastIndexOf("/script>",b)>=e.lastIndexOf("<script",b)&&(d+=a.substring(0,b)+'<a title="'+a.substr(b,c.length)+'" alt="'+a.substr(b,c.length)+'" href="'+f+'">'+a.substr(b,c.length)+"</a>",a=a.substr(b+c.length),e=a.toLowerCase(),b=-1);return d} function highlightSearchTerms(a,c,f,d){searchArray=c?[a]:a.split(" ");div=document.getElementById(d);a=div.innerHTML;for(c=0;c<searchArray.length;c++)a=doHighlight(a,searchArray[c],f);div.innerHTML=a;return!0};
//]]>
</script>
The second code: All the links will open in new tabs when people click on it. And the below code is for that purpose:
<script type='text/javascript'>
//<![CDATA[
function doHighlight(a,c,f){for(var d="",b=-1,g=c.toLowerCase(),e=a.toLowerCase();0<a.length;)b=e.indexOf(g,b+1),0>b?(d+=a,a=""):a.lastIndexOf(">",b)>=a.lastIndexOf("<",b)&&e.lastIndexOf("/script>",b)>=e.lastIndexOf("<script",b)&&(d+=a.substring(0,b)+'<a title="'+a.substr(b,c.length)+'" alt="'+a.substr(b,c.length)+'" href="'+f+'" target="_blank">'+a.substr(b,c.length)+"</a>",a=a.substr(b+c.length),e=a.toLowerCase(),b=-1);return d} function highlightSearchTerms(a,c,f,d){searchArray=c?[a]:a.split(" ");div=document.getElementById(d);a=div.innerHTML;for(c=0;c<searchArray.length;c++)a=doHighlight(a,searchArray[c],f);div.innerHTML=a;return!0};
//]]>
</script>
5. Search this code:<data:post.body/>
and change it into:
<div expr:id='"summary" + data:post.id'> <data:post.body/> </div> <script type='text/javascript'> highlightSearchTerms('Key word 1',true,'Link key word 1','summary<data:post.id/>'); highlightSearchTerms('Key word 2',true,'Link key word 2','summary<data:post.id/>'); highlightSearchTerms('Key word 3',true,'Link key word 3','summary<data:post.id/>'); </script>
Lưu ý: Mỗi blog thường có từ 2 đến 4 đoạn code <data:post.body/> như trên. Các bạn phải chèn đúng vị trí mới hiển thị.
- change Key word 1,2,3 into the key words you usually use in your blog.
- change Link key word 1,2,3 into the corresponding key words.
To add more new key word, you add the below code before </script> tag
highlightSearchTerms('Từ khóa n',true,'Link từ khóa n','summary<data:post.id/>');
6. Save template.
Now, you create new posts with the key words you insert above and see what happen!
Good luck
Good luck
Đăng nhận xét