Solved

How to get an IP Address from client

Posted on 2000-03-28
4
156 Views
Last Modified: 2008-02-01
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
Comment
Question by:yuborlau
  • 3
4 Comments
 
LVL 19

Accepted Solution

by:
daveamour earned 50 total points
ID: 2664976
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
 
LVL 19

Expert Comment

by:daveamour
ID: 2665020
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
 
LVL 19

Expert Comment

by:daveamour
ID: 2665025
This is a Javascript question isn't it?  Or did you post it in the wrong area?

Dave
0
 

Expert Comment

by:Deathead
ID: 2665250
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Javascript closure 1 35
Full Screen problem when auto scale IFRAME 2 65
bootstrap footer centering and expand problems 7 29
how can i select 3 0
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now