How to Disable / Hide Hyper links in Blogger comments

Share the love!

Hello friends well lastly i posted an amazing Script which allows you to Disable right click, CTRL key ,F12, etc. And now here is a post which will help all blogger's who are afraid of spammers and those who shared a link back with their comments, well we have many solutions for that, For example We can use comment moderation to check that the comment contains link or not but it is not a perfect solution so we are going to use The jquery which will allow you to Disable / Hide Hyper links in Blogger comments and its only two lines and works perfectly.

Lets have a look -
$("#comments p a").each(function () {
    $(this).replaceWith($(this).text());
});

That was the main jquery which will remove your links and place the text only which was inserted in that <a> tag for example -

//before
<a href="link"> Text </a>
//after
Text

Using this will remove the link and show the text which is between the a tag.

Adding it to Blogger

To add it to your blog you need to include Jquery library once in <head> section of your blog. if you haven't included till now then you can copy the below code and paste it above the </head> tag.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" />

After that just copy the below code and paste it above </body> tag.

<script type="text/javascript">
$("#comments p a").each(function () {
    $(this).replaceWith($(this).text());
});
</script>

Want to hide the links + text also?

What if you want want to hide the link + the text also well you can use the below jquery to hide them.

$('#comments p a').hide());

All Done!

Finally we have completed the process and now you can save your template and check out the magic so this was how we can Disable / Hide Hyper links in Blogger comments. Hope it works for you all, if you have a Better solution so please share it as a comment.

Comment with-

Disqus Blogger Google Facebook

0 comments:

Post a Comment

Comments :