Need Help on identifying problems in small JS script

Discussion in 'JavaScript' started by id4382, Jan 29, 2008.

  1. #1
    Ok,

    What I am attempting to do is, create a script that will HIDE a paticular line of text on my webpage IF an IP address meets certain criteria. Now, the portion of the script that hides the text works IF the "IP" section is not in the code, once I input the "IP" section, the code will not work. I have pasted the whole code on the site. I think I am just wording it wrong. Please any help would be much much appreaciated!!!!!!


    Code

    <script type="text/javascript" language=Javascript">
    <!--
    var visitorIP = Request.ServerVariables("REMOTE_ADDR");

    var list = document.getElementsByTagName("font");

    If (var visitorIP == "63.197.120.142") Then {
    for (var i=0; i < list.length; i++) {
    if (list.innerHTML.indexOf("Members Price:") > -1) {
    list[i++].style.display="none";
    if (list.innerHTML.indexOf("$") > -1) list.style.display="none";
    }
    }
    }
    //-->
    </script>
     
    id4382, Jan 29, 2008 IP
  2. Dolbz

    Dolbz Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    try putting an alert in so you can see what is in the visitorIP variable. Chances are it's not what you're expecting it to be. The visitor could be behind a proxy for example
     
    Dolbz, Jan 30, 2008 IP
  3. LittleJonSupportSite

    LittleJonSupportSite Peon

    Messages:
    386
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #3


    For debugging purposes do this:

    
    <html>
    <body>
    <p>
    <b>You are browsing this site with:</b>
    <%Response.Write(Request.ServerVariables("http_user_agent"))%>
    </p>
    <p>
    <b>Your IP address is:</b>
    <%Response.Write(Request.ServerVariables("remote_addr"))%>
    </p>
    <p>
    <b>The DNS lookup of the IP address is:</b>
    <%Response.Write(Request.ServerVariables("remote_host"))%>
    </p>
    <p>
    <b>The method used to call the page:</b>
    <%Response.Write(Request.ServerVariables("request_method"))%>
    </p>
    <p>
    <b>The server's domain name:</b>
    <%Response.Write(Request.ServerVariables("server_name"))%>
    </p>
    <p>
    <b>The server's port:</b>
    <%Response.Write(Request.ServerVariables("server_port"))%>
    </p>
    <p>
    <b>The server's software:</b>
    <%Response.Write(Request.ServerVariables("server_software"))%>
    </p>
    </body>
    </html>
    
    Code (markup):
    Examine results and adjust your logic as needed.
     
    LittleJonSupportSite, Jan 30, 2008 IP
  4. id4382

    id4382 Peon

    Messages:
    29
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Ok, well I ran your code on a few different servers and nothing came back, just the general text displayed on the page. I have a javascript that is already displaying the IP address on the page. Not sure what else I am doing wrong. I would think it is a simple straightforward script. What if you didn't even try the IP, but use a flash detection script in its place, would it not work at that point either?
     
    id4382, Jan 30, 2008 IP