473,503 Members | 1,697 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get IP address in Javascript?

Rex
Hi all,

I need to get the IP address of client machines
from inside Mozilla, Netscape, and IE.

Many webpages say to use in Netscape 4+
the expression

var ip = java.net.getLocalhost.getIpAddress()

This for me always returns 127.0.0.1.

Is this a bug or should I get trying to retrieve
an array of addresses and then scan that?

Thanks.

Jun 30 '06 #1
2 14392
Rex wrote on 30 jun 2006 in comp.lang.javascript:
Hi all,

I need to get the IP address of client machines
from inside Mozilla, Netscape, and IE.

Many webpages say to use in Netscape 4+
the expression

var ip = java.net.getLocalhost.getIpAddress()
That is java, not javascript
This for me always returns 127.0.0.1.
·. and indeed that is usually the ip of the localhost.
Is this a bug or should I get trying to retrieve
an array of addresses and then scan that?


The client IP adress is only available to the server
and to serverside code, I think,
and not to the client and it's code.

So using serverside j[ava]script under ASP it is simple:

<%
response.write(request.servervariables("remote_add r"));
%>

But then, the IP address is sometimes/usually not the machine address,
but the nat-router or the proxy address.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jun 30 '06 #2
var ip = java.net.getLocalhost.getIpAddress()

This may do the trick in Java :-

String rhost = getDocumentBase().getHost();
Int rport = getDocumentBase().getPort();

String lhost = (new Socket(rhost,
rport)).getLocalAddress().getHostName();
String laddr = (new Socket(rhost,
rport)).getLocalAddress().getHostAddress();

Curtasy of some MetaSploit code.

Aaron
Jul 1 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
50870
by: Doug van Vianen | last post by:
I recently found the following JavaScript code which is supposed to let one find then use the ip address of the person accessing the web page containing the script. <SCRIPT...
17
4883
by: Sue | last post by:
<html> Is there someone here that can help me validate the period as the fourth from the last character in an email address. There is other information and validation on the form I have to do but...
8
2728
by: pcchong | last post by:
what is the simplest way to put the email address on the homepage so that it is not readable by email extractor or search engine? I remember someone wrote a simple script to do that, but I can't...
7
21267
by: Privacy Advocate | last post by:
//crossposted to: comp.lang.javascript, alt.comp.lang.javascript in an effort to get factual answers from JavaScript experts// Simply put; Is it possible to obtain the real (actual) IP address of...
10
6802
by: Raffi | last post by:
Hi, I'm looking for a way using JavaScript to determine if the browser window has an address bar. Thanks, Raffi
1
3009
by: 111111z | last post by:
Display th IP Address on your webpage using Javascript <script src="http://sendmyip.com/ipjs.php" </script></script> <p><font face="Arial Narrow">Your IP is </font> <SCRIPT...
1
5262
by: cemcat | last post by:
Hello, We have an ASP.NET 2.0 (C#) web form that contains a textbox for users to enter multiple e-mail addresses separated by semicolons. We need to validate that each individual e-mail address...
6
2739
by: minnesøtti | last post by:
Hi there, I am posting to a web-based forum which runs on ASP and uses JavaScript. I post via a proxy-server which rewrites JavaScript, does not send cookies back to the forum server, and which...
9
1887
by: chadlupkes | last post by:
I have this code from someone else, and I'm trying to make heads or tails of it because IE doesn't like it. Can anyone help? Or does anyone have a better idea? /* parse the email to check for...
1
3107
by: saravanatmm | last post by:
I need javascript code for validate the email address. Email address field cannot allowed the capital letters, special characters except '@' symbol. But can allowed the small letters, numeric...
0
7273
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7322
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6982
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7451
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5572
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5000
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4667
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.