How To Make A Recent Comments II (JavaScript)
>> Tuesday, March 9, 2010
In previously post we have already discuss how to make a recent comments with Feed Widget. Because using the URL Feed facilities, the possibility problem that will be arrise is when the server of URL Feed that we used is going "Down". Although this was very rare.
In this article we will discuss how to make a recent comments with JavaScript.
Actually there are several reason why these method are usually avoided by the blog/site owner to use it.
The negative point's of using JavaScript, Beside can make a web page loading become slow, nearly most of the Recent Comments Tutorial using JavaScript, upload their scripts onto their external sites and provide you a code for insertion into your template, this makes the site/blog owner being worried about the possibility of inserted code that could endanger their site/blog or malicious script.
Usually, inside the code that they provide willl have the script that look like this :
<script src="http//externalsite.com/.....html/filename.js">From the blog visitors, when the page loads, their browser will visited that external site to read and run the script of .js file. That is where the problems will come "if" the .js file contained with malicious script.
</script>
Because of this situation, many users decided to configured their browser to disable the script, so that the script will not be able to see/read, and this means that your visitor couldn't be able to view your recent comments.
So.. please be carefulll if you have an external JavaScript file link make sure that there is no malicious script inside, and regularly check the script from the initial script change. More better if you have your own Script on your own server.
To avoid the problem above, in this article, we are not going to upload the script to our site and makes you link to it. We'll let you have the full JavaScript code that we have used so that you know what goes into it.
Go to your Dashboard >> Layout >> Page Elements >> and Add a Gadget >> Choose and click HTML/JavaScript gadget.
<ul><script style="text/javascript">You can set your "recent comments" display, by adjust these value..
function showrecentcomments(json) {
for (var i = 0; i < 5; i ) {
var entry = json.feed.entry[i];
var ctlink;
if (i == json.feed.entry.length) break;
for (var k = 0; k < entry.link.length; k ) {
if (entry.link[k].rel == 'alternate') {
ctlink = entry.link[k].href;
break;
}
}
ctlink = ctlink.replace("#", "#comment-");
var ptlink = ctlink.split("#");
ptlink = ptlink[0];
var txtlink = ptlink.split("/");
txtlink = txtlink[5];
txtlink = txtlink.split(".html");
txtlink = txtlink[0];
var pttitle = txtlink.replace(/-/g," ");
pttitle = pttitle.link(ptlink);
if ("content" in entry) {
var comment = entry.content.$t;}
else
if ("summary" in entry) {
var comment = entry.summary.$t;}
else var comment = "";
var re = /<\S[^>]*>/g;
comment = comment.replace(re, "");
document.write('<li>');
document.write('<a href="' ctlink '">' entry.author[0].name.$t '</a>');
document.write(' on ' pttitle);
document.write('<br/>');
if (comment.length < 100) {
document.write(comment);
}
else
{
comment = comment.substring(0, 100);
var quoteEnd = comment.lastIndexOf(" ");
comment = comment.substring(0, quoteEnd);
document.write(comment '...<a href="' ctlink '">(more)</a>');
}
}
document.write('</li>');
document.write('<div style="font-size:75%;text-align:center"><a href="http://doit2us.blogspot.com/2010/03/how-to-make-recent-comments-ii.html">Learn How To Make This Widgets</a></div>');
}
</script>
<script src="http://doit2us.blogspot.com/feeds/comments/default?alt=json-in-script&callback=showrecentcomments">
</script></ul>
<noscript>You need to enable JavaScript to read this.</noscript>
The 5 value is the number of the last comment that will appear in your recent comments gadget.
The 100 value is the number of lenght characters comment in your recent comments gadget.
Don't forget to change http://doit2us.blogspot.com with your URL Site / Blog.
After finished configuring your HTML/JavaScript (setting the value and replace the URL) click save, and view your blog. You should have a Recent Comments widget showing the latest comments posted on your Blog.
This script has been added to the anticipation if our visitor disabled the JavaScripts browser, There will be warning text below our "recent comments title" that's says "You Need to enable JavaScript to read this"
That's all... Happy controlling your Recent Comments...






23 comments:
Great post!
Wow this is really nice, comments are really important in a blog. But also having to be able to control it would be really cool. Thanks for sharing this and hope to see more latest post from you.
Been wondering how to do that, myself. Thanks for the information.
I too get confused with using javascripts in my blogger blog. Anyway I will try this one.
very nice blog :)
a good post, love this
a good post, love this!
buy mp4 player
very nice blog thank you :)
thanks for this tips..been looking for it for a while
touch screen mp4 playera good post, love this
WoW. Thank you soo much!! I gotta ask you something in regards to youtube videos. I want the videos to be displayed in a customized width & height. So could you please provide me the details/script on how to get this done..?
I usually don’t post in Blogs but your blog forced me to, amazing work.. beautiful …
Thanks so much for this! This is exactly what I was looking for bedava chat- sohbet odalari - islami chat - islami sohbet - mynet sohbet - garanti arkadas - islami sohbet - mirc sohbet - bedava sohbet - mirc script indir - dini sohbet - gay sohbet - cinsel sohbet - seviyeli sohbet - porno sohbet - sohbet et - cinsellik sohbet - sex sohbet - mirc - mirc indir - kamerali mirc - turkce mirc - sohbet siteleri - cet - Video izle - sohbet - Muhabbet - sohbet siteleri - kızlarla sohbet
greetings to all.
I would first like to thank the writers of this blog by sharing information, a few years ago I read a book called guanacaste costa rica in this book deal with questions like this one.
JavaScript is a good program and very easy to use. I don´t like a complex program. I prefer javascript because i consider it like a device very eficient and it have a good quality.
I always looking for the quality that is why i prefer to buy viagra because i always have a great result in my sexual life.
Very nice blog, is really interesting and fabulous
Really nice!!!
Thanks For Sharing Such nice Material and its very intellectual.
Nice blogging, My review is very good example.
Lindsay Rosenwald http://www.lindsayrosenwald.info/ Dr. Lindsay Rosenwald is one of the re-known venture capitalists and the hedge fund managers in the world.
I really happy to read this post, I am so glad this technical thing works.
This is so nice inform at this post. I am very impressive this good blog. Thanks share this great inform.
A good site for you guys to check out is text link adds, you should do a search in google and you will see what I’m talking about.
Your piece of writing is noteworthy. I will read your post on a regular basis and it’s very supportive.
Hello.This article was extremely fascinating, especially because I was browsing for thoughts on this topic last week.
Thanks for this blog, worth reading for. Lot of information gathered here.
Post a Comment