Solved

How to get an IP Address from client

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
dynamics crm 2011 - Web Resources 1 24
CKEditor - will not function 7 31
C3-->D3 Line Chart 4 17
What does this javascript do? 7 23
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

708 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

12 Experts available now in Live!

Get 1:1 Help Now