Results 1 to 7 of 7

Thread: Does anyone have a java script for displaying a visitor's IP address?

  1. #1

    Thread Starter
    Addicted Member Daniel_Christie's Avatar
    Join Date
    Jan 2000
    Location
    USA
    Posts
    245
    Does anyone have a java script for displaying a visitor's IP address?

    I would like to add this feature to my site

    I appreciate all of your time and effort,
    Daniel Christie
    VB 5 and 6 Enterprise Editions,
    Html, Java scipt, Vb script,
    & etc...
    http://www.qwcd.com

  2. #2
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    Here, I found this code on some free script website. The user has to be using Netscape and have Java enabled however.

    Code:
    <script language="javascript">
    <!-- 
    netscapeTest = parseInt(navigator.appVersion)
    explorerTest = navigator.appName.indexOf("Microsoft") + 1
    function netscapeThree() {
    if (navigator.javaEnabled()) {
    userDomain = java.net.InetAddress.getLocalHostName()
    txt = "I bet your hostname is " + (userDomain.toString()) + " !";
    } else {
    txt = "You are browsing without Java enabled and therefore I can\'t find out what your hostname is.";
       }
    }
    function netscapeFour() {
    if (navigator.javaEnabled()) {
    baseAddress = java.net.InetAddress.getLocalHost()
    userDomain = baseAddress.getHostName()
    txt = "I bet your hostname is " + (userDomain.toString()) + " !";
    } else {
    txt = "You are browsing without Java enabled and therefore I can\'t find out what your hostname is."; }
    }
    if ((explorerTest == "0") && (netscapeTest == "3")) { netscapeThree() }
    else if ((explorerTest == "0") && (netscapeTest == "4")) { netscapeFour() }
    else {
    txt = "It appears you are using Internet Explorer - and we can not find your hostname in that browser."
    }
    alert(txt)
    </script>
    Alcohol & calculus don't mix.
    Never drink & derive.

  3. #3
    Fanatic Member chrismitchell's Avatar
    Join Date
    Jan 2001
    Location
    With Hobbes in New Zealand
    Posts
    568
    I have a really bad feeling that it is only possible using a Java enabled engine!! but I will keep looking for you Daniel.

  4. #4
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    I wouldn't think javascript could get the local ip address, as it could be a security risk. If you're running a firewall and all web requests from your department's 50 computers use the firewalls ip address though NAT, a hacker could use the javascript to fill a hidden field in a form to enumerate your network through the firewall if he could get your users to go to his web page.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  5. #5
    Fanatic Member chrismitchell's Avatar
    Join Date
    Jan 2001
    Location
    With Hobbes in New Zealand
    Posts
    568
    There is a way round it but it requires going to a site called www.thecounter.com... they will do it for you for free... It will give you results for IP address of users, popularity of pages etc....

  6. #6
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Yeah, but on a server-side program like thecounter, you would get the firewall's ip address in my scenario, not the local ip address. The REMOTE_HOST or REMOTE_ADDR CGI variables can get the ip address of the web request easy enough in most web server technologies (Perl, ASP, etc.), but javascript interacts locally on the client.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  7. #7
    Fanatic Member chrismitchell's Avatar
    Join Date
    Jan 2001
    Location
    With Hobbes in New Zealand
    Posts
    568
    Really... I have not really looked into it... I can't get to it from my work comp.. I will keep searching!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width