Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

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

You are here: irt.org | FAQ | JavaScript | VFAQ | Q1685 [ previous next ]

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?'

©2018 Martin Webb