Solved

How to get an IP Address from client

Posted on 2000-03-28
4
158 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to combine and minify CSS and JS files 5 17
html input 8 42
What if i make webbased alternative for MS Access 5 70
on window close, not beforeunload 6 18
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…

838 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