Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1685 How do I get the IP address of the visitor?

irt.org | Knowledge Base | JavaScript | VFAQ | Q1685 [ previous next ]

Q1685 How do I get the IP address of the visitor?

In Netscape Navigator try the following, which requires Java to be enabled:

<script language="JavaScript"><!--
if (navigator.appName == 'Netscape' && navigator.javaEnabled()) {
  var myAddress = java.net.InetAddress.getLocalHost();
  var host = myAddress.getHostName();
  var ip = myAddress.getHostAddress();
  document.write('hello '+ host + '\n' + ip);
}
//--></script>

In both Internet Explorer and Netscape Navigator try:

<script src="http://jshelper.pharlap.com/utils/ipaddr.js"></script>

<script language="JavaScript"><!--
if (typeof(IPAddr) == 'undefined')
  alert('IP Address is unknown');
else
  alert('IP Address is ' + IPAddr);
//--></script>

Feedback on 'Q1685 How do I get the IP address of the visitor?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 6th July 2009. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2009 irt.org, All Rights Reserved.