hello, I know to to make an ip address show up in php and cgi but how do i make it appear in a simple html document? what code do i use to detect it?
i'm guessing id use javascript right?.
Printable View
hello, I know to to make an ip address show up in php and cgi but how do i make it appear in a simple html document? what code do i use to detect it?
i'm guessing id use javascript right?.
If you mean to display the user's IP address using a client-side script (e.g. a JavaScript) then this simply isn't possible. To my knowledge, there is no client-side feature that allows you to access a user's IP address.
Why aren't you able to use a server-side solution?
Well like Kevin said, a Server side solution would be the easiest way to implement this.
I found this somewhere deep in my hard drive for you though.
Unfortunately it only works with NS4+ with Java turned on
(not much of a solution) which I once got from the javascript source.
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
if ((navigator.appVersion.indexOf("4.") != -1) && (navigator.appName.indexOf("Netscape") != -1)){
ip = "" + java.net.InetAddress.getLocalHost().getHostAddress();
document.write("Your IP address is " + ip);
}
else {
document.write("IP Address only shown in Netscape with Java enabled!");
}
// End -->
</script>
I will try to find you an IE solution in case you can't use server side scripting.
Good Luck! :)