![]() |
| Home | Demo | Services | Features | Help | User Forum | Blog | About | |
|
#1
|
|||
|
|||
|
HI I tried following instructions from this thread:
http://forum.statcounter.com/vb/show...hlight=myspace but I am having a problem following. I am new to HTML code and don't know all the rules. I am trying to block someone from a personal homepage - not myspace. I want them to be redirected elsewhere. I used this code highlighted in blue to show you. I used it EXACTLY like this, spaces and all. Each line exactly the way it appears. Is this correct? <script language="javascript" type="text/javascript"> <!-- var ip = '<!--#echo var="REMOTE_ADDR"-->'; if (ip == "xxx.xxx.xxx.xxx") { alert("You are visiting this site from a blocked IP address " +ip); window.location="http://www.aol.com" } // --> </script> I attempted to block my own IP first to see if it would work. Nothing. I am using Frontpage and I placed the code up top under the <body> section. Above that I have the head and title sections. There is no template, just what I made with tables and text in the "normal" view. I also have the stat counter (invisible) on the same page. The code is inserted near the bottom and it is working perfectly for me. Any guidance would be very much appreciated. ~Dana~ |
|
#2
|
||||
|
||||
|
That script goes after the <head> tag, and before the </head> tag. Not in the body section.
Make sure you're not using design mode or layout mode. It has to be code view mode, source code mode or html mode - whatever it may be called in Frontpage. But another problem you'll have is that this script requires that the page where you use it has to be suffixed by .shtml not .html , because it uses a SSI (server side include) directive. The server only interprets that at all if the file is suffixed by .shtml .
__________________
Christina >>Forum Moderator<< Please do not PM me for support. The forum is here for that. |
|
#3
|
|||
|
|||
|
Thanks so much! I will try that out. I hope I do it right
|
|
#4
|
|||
|
|||
|
I have tried this out on my IP, and it works as far as blocking goes, but rather than getting redirected to the designated webpage, I get this message:
Directory Listing Denied This Virtual Directory does not allow contents to be listed. Is there something I am doing wrong or is there another way to have the blocked user redirected to another website - for example, the online dictionary definition of "stalker"? Another question, will statcounter log whether or not this person continues to try to access my page if they are blocked? Last edited by Dana; 01-10-2006 at 11:40 PM. |
|
#5
|
||||
|
||||
|
Quote:
That visit won't get logged actually since the script happens before the rest of the page loads. You cannot place that script elsewhere though , as it will give an error, redirection has to happen before anything of the page is output by html.
__________________
Christina >>Forum Moderator<< Please do not PM me for support. The forum is here for that. |
|
#6
|
|||
|
|||
|
LOL okay I am literally trying to redirect the deranged visitor to this site: http://www.urbandictionary.com/define.php?term=Mental
Can I just paste it in there? Do I need to add a hyperlink to that? Thanks so much for your help!!! |
|
#7
|
||||
|
||||
|
It has to simply be used in place of the aol url from the earlier example.
[html] <script language="javascript" type="text/javascript"> <!-- var ip = '<!--#echo var="REMOTE_ADDR"-->'; if (ip == "xxx.xxx.xxx.xxx") { alert("You are visiting this site from a blocked IP address " +ip); window.location="http://www.urbandictionary.com/define.php?term=Mental"; } // --> </script> [/html] Of course this won't ever work for a visitor with a javascript disabled browser. And dont' remember you need to save yoru page as .shtml as it is using an SSI construct.
__________________
Christina >>Forum Moderator<< Please do not PM me for support. The forum is here for that. Last edited by webado; 01-11-2006 at 12:47 AM. |
|
#8
|
|||
|
|||
|
Chrisoc, thank you so much for your help! I really appreciate it!!!
Okay, when trying it out yesterday afternoon, I saved as a .shtml and blocked my own IP. I was blocked, just not redirected. That is when I wrote back in the forum asking if I was doing something wrong because I was not getting redirected to the designated site. I wondered if I had the spacing messed up. I pasted the new address right over the AOL address from the sample. Can you think of anything crucial that would prevent that redirection from working? From the things you have mentioned, I believe I have gotten them taken care of. BTW, have you ever tried to block & redirect anyone? According to statcounter, the visitor has Java enabled. I also have Java enabled and pretty much have the same set up as the visitor that I want to block and send elsewhere. When I blocked myself, I did not get the message in quotes on the code. Is this "You are visiting this site from a blocked IP address " supposed to appear as well? Before I block the actual person, I am hoping to try it out and see exactly what they will see. |
|
#9
|
||||
|
||||
|
I don't know how you actually did it.
Here's what I'm doing (and make sure the IP address you are testing with is correct at that moment - to be used instead of 255.255.255.255 which is below): [html] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="EN"> <head> <title>To ban or not to ban</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script language="javascript" type="text/javascript"> var ip = '<!--#echo var="REMOTE_ADDR"-->'; if (ip =='255.255.255.255') { alert("You are visiting this site from a blocked IP address " +ip); window.location="http://www.urbandictionary.com/define.php?term=Mental"; } </script> </head> <body bgcolor="#FFFFFF" text="#000000"> <p> </p> <p> </p> <p align="center"><b>Page content here.</b></p> </body> </html> [/html] For the ip address substitute the one you have at the moment you are testing. Also for the page to redirect to use a url of your own, either on your website or somewhere else (just not mine please But as I said, if the visitor does not have javascript enabled, the redirection will not happen.
__________________
Christina >>Forum Moderator<< Please do not PM me for support. The forum is here for that. Last edited by webado; 01-11-2006 at 02:07 PM. |
|
#10
|
|||
|
|||
|
This code worked for me but the only problem is that I'm using blogger, generating a new page every time I post to my blog. I've blocked my stalker from my index page. I'm wondering if there's a way to block my stalker from accessing every page of my website.
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|