Re: Javascript newbie - Please Help



Response to "StefanoElle" <onde@xxxxxxxxxxxx>:

var BaseURL;
if (ip1 == ip2)
BaseURL = '192.168.1.5'
else
BaseURL = 'www.mysite.com:9000';

Thank you for the answer. How can I get ip1 and ip2 ? I mean, how
to get the ip address of the user and the ipaddress of
www.mysite.com ?

<begin off-topic response>

<script type="text/javascript">
// <![CDATA[
<?php
// User's IP address
print 'var ip1 = ' . $_SERVER['REMOTE_ADDR'] . ';';
// Resolve the IP for the current host
print 'var ip2 = ' . gethostbyname('www.mysite.com') . ';';
?>
// Evertjan's code here...
// ]]>
</script>

If you do not know why you are using:

1. type="text/javascript"
2. // <![CDATA[
3. // ]]>

....then it is a good indication you should not be using them.

I'll not bother debating or arguing why it is or is not good -- I'm
sure someone else will though.

4. See additional caveats for gethostbyname by perusing the manual.

</end off-topic response>

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
.



Relevant Pages