SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot Technics's Avatar
    Join Date
    Aug 2000
    Posts
    184
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hello, I know to to make an ip address show up in php and cgi but how do i make it appear in a simple html document? what code do i use to detect it?

    i'm guessing id use javascript right?.

  2. #2
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    If you mean to display the user's IP address using a client-side script (e.g. a JavaScript) then this simply isn't possible. To my knowledge, there is no client-side feature that allows you to access a user's IP address.

    Why aren't you able to use a server-side solution?
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  3. #3
    SitePoint Addict
    Join Date
    Aug 2000
    Posts
    248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well like Kevin said, a Server side solution would be the easiest way to implement this.

    I found this somewhere deep in my hard drive for you though.
    Unfortunately it only works with NS4+ with Java turned on
    (not much of a solution) which I once got from the javascript source.

    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin

    <!-- This script and many more are available free online at -->
    <!-- The JavaScript Source!! http://javascript.internet.com -->

    if ((navigator.appVersion.indexOf("4.") != -1) && (navigator.appName.indexOf("Netscape") != -1)){
    ip = "" + java.net.InetAddress.getLocalHost().getHostAddress();
    document.write("Your IP address is " + ip);
    }
    else {
    document.write("IP Address only shown in Netscape with Java enabled!");
    }
    // End -->
    </script>

    I will try to find you an IE solution in case you can't use server side scripting.


    Good Luck!



Bookmarks

Posting Permissions

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