Javascript Problems
hey...i'm trying to put a javascript inside an html document that displays the persons host and IP address to let them know that they are not doing this stuff in secret...heres what i have (and it doesnt work)
<script language="javascript">
myaddress=java.net.inetaddress.getlocalhost();
myaddress2=java.net.inetaddress.getlocalhost();
host=myaddress.gethostname();
ip=myaddress2.gethostaddress();
document.write("Your hostname is: "+host);
document.write("<br>Your IP address is: "+ip);
</script>
help me out please!
nike_guy_man posted this at 19:00 — 11th May 2002.
They have: 840 posts
Joined: Sep 2000
I'm not a huge Javascript person, but I do think that you need to declare the variables first??? Not sure though
Anyone else have any ideas?
kb posted this at 20:31 — 11th May 2002.
He has: 1,380 posts
Joined: Feb 2002
i tried the definition of variables...it didnt work
Suzanne posted this at 20:33 — 11th May 2002.
She has: 5,507 posts
Joined: Feb 2000
define the functions?
I've never tried this with JavaScript, sorry.
http://ipid.shat.net:80/
Suzanne posted this at 20:42 — 11th May 2002.
She has: 5,507 posts
Joined: Feb 2000
http://sharkysoft.com/tutorials/jsa/content/040.html has what you're looking for, I think.
dk01 posted this at 06:35 — 12th May 2002.
He has: 516 posts
Joined: Mar 2002
That looks like it should work but it doesn't for me. I think a perl script would be the only way to get a result almost every time. Using java seems to be very inconsistant.
-dk
kb posted this at 00:53 — 14th May 2002.
He has: 1,380 posts
Joined: Feb 2002
then how would i do it in PERL
Suzanne posted this at 01:01 — 14th May 2002.
She has: 5,507 posts
Joined: Feb 2000
I would personally use either SSI or Php.
For SSI:
http://www.wdvl.com/Authoring/SSI/Intro/cgi.html
Abhishek Reddy posted this at 06:24 — 14th May 2002.
He has: 3,348 posts
Joined: Jul 2001
You must declare using var before the variable names.
e.g.
var myaddress ...
Abhishek Reddy posted this at 06:54 — 14th May 2002.
He has: 3,348 posts
Joined: Jul 2001
Hmm... just checked again on Google. Look what I found at http://javascript.internet.com/user-details/hostname.html
I tested the following code in Netscape 4.7 and it worked just fine.
Code from http://www.irt.org/discus/messages/25/236.html
<script LANGUAGE="JavaScript">
myAddress=java.net.InetAddress.getLocalHost();
myAddress2=java.net.InetAddress.getLocalHost();
host=myAddress.getHostName();
ip=myAddress2.getHostAddress();
document.write("Your host name is "+host);
document.write("<BR>Your IP address is "+ip);
</script>
Suzanne posted this at 06:57 — 14th May 2002.
She has: 5,507 posts
Joined: Feb 2000
Isn't that the exact same code as above and in the Java link?
I think it's better to do it server-side -- more reliable and no client side errors to screw you up.
dk01 posted this at 11:35 — 14th May 2002.
He has: 516 posts
Joined: Mar 2002
Yes Perl, Php, or ssi. However you like it and whatever capabilities your server has.
-dk
Abhishek Reddy posted this at 04:52 — 15th May 2002.
He has: 3,348 posts
Joined: Jul 2001
Yes, it looks like it, except for capitalisation of a few characters, and that the first snippet didn't work but the one in the link did.
I agree that server side is the way to go for this.
Suzanne posted this at 05:45 — 15th May 2002.
She has: 5,507 posts
Joined: Feb 2000
darn details! thanks for clarifying!
nicora posted this at 19:25 — 15th May 2002.
He has: 267 posts
Joined: Nov 2001
I would have to agree, server side scripting would be the best solution... whatever langauge is available
CF = #CGI.remote_host#
In fact I think that REMOTE_HOST would work for almost any langauge, I know it does in asp. I have been wrong before tho
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.