Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get IP and hostname

Status
Not open for further replies.

Eek

Technical User
Feb 4, 2001
34
0
0
CA
I'm able to get the user's IP address but how can I get the HostName ?

Example :

IP : 121.254.65.45

Host name : 151gf-121.254-hst.videotron.ca
 
Yea but you can only get it using netscape. Otherwise you'll have to use some java. The best thing to do is use a server side language to do that. Give me a minute and I'll get you the code
Matt
 
Code:
<SCRIPt>
if (navigator.appName=='Netscape') {
document.write(java.net.InetAddress.getLocalHost().getHostAddress()+'<P>')
document.write(java.net.InetAddress.getLocalHost().getHostName())
} else {
document.write('You are using something other than netscape');
}

</script>
 
whoops heres a better if statement to check

Code:
<SCRIPt>
if (navigator.javaEnabled()) {
document.write(java.net.InetAddress.getLocalHost().getHostAddress()+'<P>');
document.write(java.net.InetAddress.getLocalHost().getHostName());

} else {
document.write('You do not have java enabled');
}

</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top