|
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?'
|
|
Copyright © 1996-2008 irt.org, All Rights Reserved.