473,657 Members | 2,702 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.getLoc alhost.getIpAdd ress()

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 14401
Rex wrote on 30 jun 2006 in comp.lang.javas cript:
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.getLoc alhost.getIpAdd ress()
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.serverv ariables("remot e_addr"));
%>

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.getLoc alhost.getIpAdd ress()

This may do the trick in Java :-

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

String lhost = (new Socket(rhost,
rport)).getLoca lAddress().getH ostName();
String laddr = (new Socket(rhost,
rport)).getLoca lAddress().getH ostAddress();

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
50889
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 LANGUAGE="JavaScript"> <!-- var ip = '<!--#echo var="REMOTE_ADDR"-->'; function ipval() { document.myform.ipadd.value=ip;
17
4901
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 the period in the email address is the only part I am having problems with. I have posted part of my code below. Any help would be greatly appreciated. THANKS !
8
2743
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 find it now. Anyone know about this? Thanks. pcchong
7
21289
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 someone (client) that visits a web site through an anonymous proxy if this person ONLY has JavaScript enabled in their browser? This is NOT a question about PHP, perl, VBScript, Java(.class), or ActiveX. Let us _only_ deal with JavaScript for...
10
6820
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
3029
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 LANGUAGE="JavaScript"> document.title = "Your IP is "+ip; document.write(ip) </script> see http://www.sendmyip.com/ipjava.htm
1
5266
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 entered is a valid e-mail address format. We've added a CustomValidator to perform this validation. We have the server-side validation working fine, but now we need to add some client-side validation via JavaScript. We are having difficulties...
6
2755
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 changes its IP address every few minutes within the whole class A network. The moderator says he banned my IP address (let's put the moral issues of it aside for the sake of the technical discussion). This means he banned the whole network of...
9
1893
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 valid form */ function parseemail(str) { str = trim(str); <?if(preg_match("/MSIE 5.0;/", $_SERVER)) // this is IE 5.0
1
3119
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 numbers. Now i use this script for validate the email address. But it allows the cpital letters otherwise its working correctly. SCRIPT FUNCTION ************************************************
0
8732
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8605
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7324
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6163
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4302
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1953
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1611
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.