• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 166
  • Last Modified:

How to get an IP Address from client

when I use
myAddress=java.net.InetAddress.getLocalHost();
I got "java is undefined"  error

If I can't use this( in NS), what can I use to get the client's ip address?

thanks

lewis





0
yuborlau
Asked:
yuborlau
  • 3
1 Solution
 
daveamourCommented:
I'm not sure that you can do this with Javascript.  Maybe you can but I don't know how.

You can certainly do this with ASP though

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<BODY>
  <P>Your Ip Address is <%=Request.ServerVariables("REMOTE_ADDR")%> </P>
</BODY>
</HTML>

For an example of this look at

http://www4.ewebcity.com/daveamour

Look at the bottom left hadn corner

You can get free ASP hosting by the way at http://www.ewebcity.com and this is all without banners or pop up ads.

Worth checking out if your not into ASP.

Cheers

Dave
0
 
daveamourCommented:
Further comment

As far as I am aware the following are the only Browser/Client properties available through Javascript.

Note some of these are arrays such as plugin

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<BODY>

<SCRIPT LANGUAGE=javascript>
<!--
  document.write ("appCodeName - " + navigator.appCodeName + "<Br>");
  document.write ("appMinorVersion - " + navigator.appMinorVersion + "<Br>");
  document.write ("appName - " + navigator.appName + "<Br>");
  document.write ("appVersion - " + navigator.appVersion + "<Br>");
  document.write ("cookieEnabled - " + navigator.cookieEnabled + "<Br>");
  document.write ("cpuClass - " + navigator.cpuClass + "<Br>");
  document.write ("mimeTypes - " + navigator.mimeTypes + "<Br>");
  document.write ("onLine - " + navigator.onLine + "<Br>");
  document.write ("opsProfile - " + navigator.opsProfile + "<Br>");
  document.write ("platform - " + navigator.platform + "<Br>");
  document.write ("plugins - " + navigator.plugins + "<Br>");
  document.write ("systemLanguage - " + navigator.systemLanguage + "<Br>");
  document.write ("userAgent - " + navigator.userAgent + "<Br>");
  document.write ("userLanguage - " + navigator.userLanguage + "<Br>");
  document.write ("userProfile - " + navigator.userProfile + "<Br>");
//-->
</SCRIPT>

</BODY>
</HTML>

Dave
0
 
daveamourCommented:
This is a Javascript question isn't it?  Or did you post it in the wrong area?

Dave
0
 
DeatheadCommented:
This is a cross browser IP grabber.. It works in IE due to a CGI call... Enjoy


<!--   REQUIRED BY GGScript   -->
  <script language="JavaScript"> var GG_js = 1.0; </script>
  <script language="JavaScript1.1"> var GG_js = 1.1; </script>
  <script language="JavaScript1.2"> var GG_js = 1.2; </script>
  <script>
   <!--   REQUIRED BY GGScript   -->
    var GG_sk = "Unknown";var GG_cd = 0;var GG_sw = 0;var GG_sh = 0;var GG_dr = GG_sk;var GG_du = GG_sk;var GG_an = GG_sk;var GG_av = GG_sk;var GG_np = GG_sk;var GG_ua = GG_sk;var GG_IPAddr = GG_sk;
    document.URL?GG_du=document.URL:GG_du=GG_sk;document.referrer?GG_dr=document.referrer:GG_dr=GG_sk;navigator.appName?GG_an=navigator.appName:GG_an=GG_sk;navigator.appVersion?GG_av=navigator.appVersion:GG_av=GG_sk;navigator.userAgent?GG_ua=navigator.userAgent:GG_ua=GG_sk;
    if(GG_js >= 1.2)
    {
     if(screen.width)GG_sw=screen.width;if(screen.height)GG_sh=screen.height;if(screen.colorDepth)GG_cd=screen.colorDepth;
     GG_cd==2?GG_cd="4":(GG_cd==4?GG_cd="16":(GG_cd==8?GG_cd="256":(GG_cd==16?GG_cd="65K":(GG_cd==24?GG_cd="16.7M":(GG_cd==32?GG_cd="16.7M":dd=0)))));
     navigator.platform?GG_np=navigator.platform:GG_np=GG_sk;
    }
    if(GG_js >= 1.1)
     document.write("<script language=\"JavaScript1.1\" src=\"http://www.ggscript.com/GGScript/GG_IP.cgi?"+GG_du+"^"+escape(GG_an)+"^"+escape(GG_ua)+"^"+escape(GG_np)+"^"+GG_sw+"^"+GG_sh+"^"+GG_cd+"^"+escape(GG_dr)+"\"></"+"script>");
    // -->
   </script>
   <script>
    <!--
     // REQUIRED BY GGScript
     // do not remove, Netscape 3 needs this...
      document.write(" ");
    // -->
   </script>

<script>
    <!--
     // This is for the IP Address
     if(GG_IPAddr != GG_sk)
      document.write("<B>Your IP address:</B><BR>"+GG_IPAddr+"<BR><BR>")

    // -->




   </script>
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now