How To Ban Unlimited IP Address with JavaScript in Blogger

At this time and age, tons of hackers are revolving around in the blogosphere with only one motive to hack as many websites as they can. Therefore, to protect our blog from brute force attacks or hijacking it’s essential to have a strong security system. There is no doubt that Blogger Platform has the indestructible security whenever we compare it with one of the leading Blogging Platform WordPress. Since, Blogger enabled websites works on Google’s Server, so it is extremely tough to hack or hijacked them. However, sometimes content cloning, click bombing, and spam commenting becomes the biggest pain. In this situation, a person tries to find the culprit and restrict it from access his website. In other words, we can say that banning his IP Address.  

How The IP Address Banning Works?

Fundamentally, no one wants to restrict his users from visiting his website but repeated violation in terms or services annoys a website and hence the end results aren’t amusing for the spammers. There are no appropriate ways of banning a Certain IP, but there are few alternatives that do the job quite effortlessly.  To Ban certain IP Address we will utilize a JavaScript coding which will automatically redirect unwanted IPs to a new destination. The Script is extremely flexible because we can add unlimited IPs and can also customize the redirecting destination URL.

Whenever, a Visitor who’s IP is in the Blacklist would visit your website he will get a Message that, “Your IP address XYZ is Banned” and then, within seconds it will redirect the banned visitor to a prescribed destination URL. We have attached a screenshot below so everyone can easily understand its meaning.

How To Redirect Unwanted IP Addresses via JavaScript In Blogger? 

The JavaScript file will reduce your website’s load time because in this Jquery coding, we have used modest JavaScript, no complexity involved at all. Consider the following instruction. (Remember: The same technique can be applied on any platform i.e. WordPress, Joomla and etc.).
  • Go To >> Your Site >> Template.
  • Now just Select Edit HTML >> Proceed
  • Then within the template search for </head> and above it paste the Following JavaScript coding. Remember: Don’t paste this Coding in the gadget AREA i.e. HTML/JavaScript otherwise it could destroy your site maliciously. This is the reason, why it’s essential that you only add it in your Template portion rather then adding it into your Add a gadget area.
var ip = 'Your-IP-Here';
function banned(){
alert("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Attention!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\nYour ip address has been banned!");
function ban(){
if (ip == "Banned-IP-1" || ip == "Banned-IP-2" || ip == "Banned-IP-3"   )  {

  • Replace Your-IP-Here with your IP Address so, the script could fetch your LocalHost. Without adding your personal IP Address, this script would stop working. 
  • Last but certainly not the least Replace Banned-IP-1 the IP Address that you want to ban. There is no limit for IP Banning. Therefore, we can ban unlimited IPs without any problem whatsoever.
All Done: After Add your and the victims IP Address save the Template by pressing "Save Template" Button. Now your site is safe from unwanted users.

From The Editor’s Desk:

Though, we have preciously shared a detailed tutorial on how to Block IP Address in Blogger blog but that tutorial allows to restrict only three IP Address. Therefore, we decided to develop a script that could help users to ban unlimited IP Addresses. Since, we can’t use PHP in Blogger Platform. Thus, we tried to play with JavaScript, and it works like a charm. The script is bug free and would not provide any laggy experience. What are your thoughts about this technique? Take a lot care till then, Peace, Blessings and Happy Blocking.

The Editorial Team of MyBloggerLab consists of a group of Professional Blogger geeks Led by Syed Faizan Ali (Founder of MyBloggerLab).

Comment With:
Choose Wisely!


December 20, 2012 at 4:38 AM

Gr8 tutorial....
but hackers & spammers are already using Vpn's and IP hiding tools , they can change their ip in less then a mint...

Editorial Team MOD
December 20, 2012 at 4:40 AM

Well, Since this script allows to add unlimited IP Address so we can block as many users. Its not possible to ban every single spammer but it would help users to a great extent.

Thanks for waiting and leaving your comment. Peace and Blessings

December 20, 2012 at 8:08 AM

There are freewares which allow you to mask your IP and browse websites using proxies.Also if you disable your browsers javascript , you can overcome this trick.All i want to say is that this method of securing your blog is very tensile and has many loopholes :( PEACE

December 20, 2012 at 11:25 AM

agreed with Kapse.
You have used a very simple function in which IP's are hard coded (pre-defined).This can be workable on only few spammers who do not know technical details.

Editorial Team MOD
December 20, 2012 at 1:56 PM

Well, in this world there are two types of people. One who are engineer like you and other a normal Guy like me. You are correct that by disabling JavaScript this script would stop working but on the same time it is better then nothing.

As you Know That, PHP can't be used on Blogger platform. Therefore, we have to utilize what we have. Hope that Helps. Peace

Editorial Team MOD
December 20, 2012 at 1:59 PM

Sis, you're saying this because you have read this tutorial and knows that i have used JavaScript. Those who don't even know that this effect is generated from JavaScript could do much about it.

Proxy sites do Help But, We can also Include Their IPs Too. Since, it supports unlimited IPs banning.

Rather then Watching each other faces, its better to have something then nothing :).. Peace

December 20, 2012 at 8:35 PM

well, most of the spammers are smart and they can use online proxies or tools to access websites. If there were any system to block comments of a particular user, like, then it could be really useful.

December 21, 2012 at 1:05 AM

Great post @syed But would you give me google search image redirect script for blogger. i want to redirect my blog images from google. i have used some scripts but when i use those scripts on my blog. they running well but my blogger editor automatic redirect. and after that i got blank page. after install this scripts i can access in my blogger editor page. I give this scrips in this link. please check it. i install this scripts this tutorial according.

if you have any suggestion about this scripts and have another scripts give me.

December 21, 2012 at 9:17 AM

ahan, I am saying this because i know my brother will soon come up with something more efficient:-)
I won't say again n again that you are doing good.I will just point out deficiencies:p

Editorial Team MOD
December 22, 2012 at 12:24 AM

Hopefully, I Would try to Come up with something really Great, Thanks for the Boost Up Sis.

Editorial Team MOD
December 22, 2012 at 12:25 AM

Dude, Since The Commenting System is owned by Google. Therefore, we can't do modification because all the Data is controlled by Blogger Team. Lets hope we could do something with this issue.

Editorial Team MOD
December 22, 2012 at 12:26 AM

Rahul I Guess We would write a Complete tutorial on it because the topic looks spicy and would surely help our Readers. Wait for few days till we develop some scripts. Peace

March 7, 2013 at 12:17 PM

Hi am The Rux, very well your website to help those who need a little guidance.

On this subject because not working, the blocked ip? the (script) this goes before or later.
Aggregate to favorites friend :-)

Editorial Team MOD
March 7, 2013 at 12:34 PM

It works pretty fine, you can even add your IP and it will block that too. Works fine!

March 7, 2013 at 12:39 PM

if know it works great but because I see it work??? put my ip but I see nothing...


March 7, 2013 at 12:42 PM

One more thing is possible to change the scrollbar up and down...

Editorial Team MOD
March 7, 2013 at 10:09 PM

I Think, you are not writing your IP Address correctly.Script is fab, must be only you who is facing the error.

Editorial Team MOD
March 7, 2013 at 10:11 PM

Please, don't discuss such topics which doesn't relates the article. Peace

June 3, 2013 at 4:39 AM

this method is not worth because we can easily disable all the javascripts / disable specific javascripts in the other we can edit the cookies :)

Editorial Team MOD
June 3, 2013 at 11:40 PM

Do you know any better way? If yes then shoot it to me.

January 20, 2016 at 11:58 AM

The best way is banning a masking host ( their internet connection ), because at that point they wont be able to change their IP and rejoin the site. Once you ban their internet service from your site, it wont matter how many times they change their IP. It's an old trick that IRC uses. Since these comments are old, that means blogger has changed significantly. Well I hope I was able to help.

Post a Comment

We’re eager to see your comment. However, Please Keep in mind that all comments are moderated manually by our human reviewers according to our comment policy, and all the links are nofollow. Using Keywords in the name field area is forbidden. Let’s enjoy a personal and evocative conversation.

Helping You to do Cool Things With Blogger Since 2012™.

© Copyright 2012 - 2018. MBL Networks, All Rights are Strictly Reserved.