|
-
Nov 13th, 2000, 03:01 PM
#1
Thread Starter
Addicted Member
Does anyone have a java script for displaying a visitor's IP address?
I would like to add this feature to my site
I appreciate all of your time and effort,
Daniel Christie
VB 5 and 6 Enterprise Editions,
Html, Java scipt, Vb script,
& etc...
http://www.qwcd.com
-
Apr 23rd, 2001, 08:54 PM
#2
Fanatic Member
Here, I found this code on some free script website. The user has to be using Netscape and have Java enabled however.
Code:
<script language="javascript">
<!--
netscapeTest = parseInt(navigator.appVersion)
explorerTest = navigator.appName.indexOf("Microsoft") + 1
function netscapeThree() {
if (navigator.javaEnabled()) {
userDomain = java.net.InetAddress.getLocalHostName()
txt = "I bet your hostname is " + (userDomain.toString()) + " !";
} else {
txt = "You are browsing without Java enabled and therefore I can\'t find out what your hostname is.";
}
}
function netscapeFour() {
if (navigator.javaEnabled()) {
baseAddress = java.net.InetAddress.getLocalHost()
userDomain = baseAddress.getHostName()
txt = "I bet your hostname is " + (userDomain.toString()) + " !";
} else {
txt = "You are browsing without Java enabled and therefore I can\'t find out what your hostname is."; }
}
if ((explorerTest == "0") && (netscapeTest == "3")) { netscapeThree() }
else if ((explorerTest == "0") && (netscapeTest == "4")) { netscapeFour() }
else {
txt = "It appears you are using Internet Explorer - and we can not find your hostname in that browser."
}
alert(txt)
</script>
Alcohol & calculus don't mix.
Never drink & derive.
-
Apr 24th, 2001, 02:44 AM
#3
Fanatic Member
I have a really bad feeling that it is only possible using a Java enabled engine!! but I will keep looking for you Daniel.
-
Apr 24th, 2001, 06:44 AM
#4
Black Cat
I wouldn't think javascript could get the local ip address, as it could be a security risk. If you're running a firewall and all web requests from your department's 50 computers use the firewalls ip address though NAT, a hacker could use the javascript to fill a hidden field in a form to enumerate your network through the firewall if he could get your users to go to his web page.
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
-
Apr 24th, 2001, 07:20 AM
#5
Fanatic Member
There is a way round it but it requires going to a site called www.thecounter.com... they will do it for you for free... It will give you results for IP address of users, popularity of pages etc....
-
Apr 24th, 2001, 08:41 AM
#6
Black Cat
Yeah, but on a server-side program like thecounter, you would get the firewall's ip address in my scenario, not the local ip address. The REMOTE_HOST or REMOTE_ADDR CGI variables can get the ip address of the web request easy enough in most web server technologies (Perl, ASP, etc.), but javascript interacts locally on the client.
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
-
Apr 24th, 2001, 09:27 AM
#7
Fanatic Member
Really... I have not really looked into it... I can't get to it from my work comp.. I will keep searching!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|