I've only done a small amount of Javascript a few years ago at work. Mainly VBScript these days (ASP etc).
Still, try this out. Was on Planet source code (my fave site).
//**************************************
//
// Name: Detect IP address and hostname
// Description:Detect IP address and hos
// tname
// By: Jayant The TechGuy
//
//This code is copyrighted and has// limited warranties.Please see http://
// www.Planet-Source-Code.com/vb/scripts/Sh
// owCode.asp?txtCodeId=2106&lngWId=2//for details.//**************************************
//
<!DOCTYPE HTML public "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Detect IP address and hostname</TITLE>
</HEAD>
<BODY>
<BODY>
<!-- Script by Jayant Kumar Gandhi - www.jayantgandhi.com -->
<SCRIPT LANGUAGE=JAVASCRIPT>
<!-- Begin
// detect whether IE or netscape
netscapeTest = parseInt(navigator.appVersion)
explorerTest = navigator.appName.indexOf("Microsoft") + 1
// detect hostname for Netscape 3
function netscapeThree() {
if (navigator.javaEnabled()) {
userDomain = java.net.InetAddress.getLocalHostName()
return (userDomain.toString())
} else {
return null
}
}
// detect hostname and IP address for Ne
// tscape 4
// Note here baseaddress is in format 'h
// ostname/ip-address'
// getHostName() gets us the host name
function netscapeFour() {
if (navigator.javaEnabled()) {
baseAddress = java.net.InetAddress.getLocalHost()
userDomain = baseAddress.getHostName()
return (userDomain.toString())
} else {
return null
}
}
if ((explorerTest == "0") && (netscapeTest == "3")) {
domainName = netscapeThree()
}
else if ((explorerTest == "0") && (netscapeTest == "4")) {
domainName = netscapeFour()
}
else {
domainName = "Domain name can be detected only on Netscape and compatible browsers. <BR>Internet Explorer users must use Netscape to see the actual result"
}
document.write(domainName)
// End -->
</SCRIPT>
</BODY>
</HTML>
Hope that comes out right.
Cheers
I am 99% probably lying in bed right now... so don't blame me for crappy typing